Commit 80d493c1 by Victor Wang

重构模板的初始化方法

parent 9f66c58e
...@@ -3,6 +3,8 @@ module IGeTui ...@@ -3,6 +3,8 @@ module IGeTui
attr_accessor :transmission_type, :transmission_content attr_accessor :transmission_type, :transmission_content
def initialize def initialize
@transmission_type = 0
@transmission_content = ''
@push_info = nil @push_info = nil
end end
......
module IGeTui module IGeTui
class LinkTemplate < BaseTemplate class LinkTemplate < BaseTemplate
attr_accessor :title, :text, :logo, :logo_url, :url STRING_ATTRIBUTES = %i(title text logo logo_url url).freeze
attr_accessor :is_ring, :is_vibrate, :is_clearable BOOLEAN_ATTRIBUTES = %i(is_ring is_vibrate is_clearable).freeze
attr_accessor *STRING_ATTRIBUTES, *BOOLEAN_ATTRIBUTES
def initialize def initialize
@title = ''
@text = ''
@logo = ''
@logo_url = ''
@transmission_type = 0
@transmission_content = ''
@is_ring = true
@is_vibrate = true
@is_clearable = true
super super
STRING_ATTRIBUTES.each { |attr| instance_variable_set("@#{attr}", '') }
BOOLEAN_ATTRIBUTES.each { |attr| instance_variable_set("@#{attr}", true) }
end end
def get_action_chain def get_action_chain
......
module IGeTui module IGeTui
class NotificationTemplate < BaseTemplate class NotificationTemplate < BaseTemplate
attr_accessor :title, :text, :logo, :logo_url STRING_ATTRIBUTES = %i(title text logo logo_url).freeze
attr_accessor :is_ring, :is_vibrate, :is_clearable BOOLEAN_ATTRIBUTES = %i(is_ring is_vibrate is_clearable).freeze
attr_accessor *STRING_ATTRIBUTES, *BOOLEAN_ATTRIBUTES
def initialize def initialize
@title = ''
@text = ''
@logo = ''
@logo_url = ''
@transmission_type = 0
@transmission_content = ''
@is_ring = true
@is_vibrate = true
@is_clearable = true
super super
STRING_ATTRIBUTES.each { |attr| instance_variable_set("@#{attr}", '') }
BOOLEAN_ATTRIBUTES.each { |attr| instance_variable_set("@#{attr}", true) }
end end
def get_action_chain def get_action_chain
......
module IGeTui module IGeTui
class NotyPopLoadTemplate < BaseTemplate class NotyPopLoadTemplate < BaseTemplate
attr_accessor :title, :text, :logo, :logo_url STRING_ATTRIBUTES = %i(
attr_accessor :is_ring, :is_vibrate, :is_clearable title text logo logo_url
attr_accessor :pop_title, :pop_text, :pop_image pop_title pop_text pop_image
attr_accessor :pop_button_1, :pop_button_2 pop_button_1 pop_button_2
attr_accessor :load_icon, :load_title, :load_url load_icon load_title load_url
attr_accessor :android_mask, :symbia_mask, :ios_mask android_mask symbia_mask ios_mask
attr_accessor :is_auto_install, :is_active ).freeze
BOOLEAN_ATTRIBUTES_OF_TRUE = %i(is_ring is_vibrate is_clearable).freeze
BOOLEAN_ATTRIBUTES_OF_FALSE = %i(is_auto_install is_active).freeze
attr_accessor *STRING_ATTRIBUTES, *BOOLEAN_ATTRIBUTES_OF_TRUE, *BOOLEAN_ATTRIBUTES_OF_FALSE
def initialize def initialize
@title = ''
@text = ''
@logo = ''
@logo_url = ''
@pop_title = ''
@pop_text = ''
@pop_image = ''
@pop_button_1 = ''
@pop_button_2 = ''
@load_icon = ''
@load_title = ''
@load_url = ''
@transmission_type = 0
@transmission_content = ''
@is_ring = true
@is_vibrate = true
@is_clearable = true
@android_mask = ''
@symbia_mask = ''
@ios_mask = ''
@is_auto_install = false
@is_active = false
super super
STRING_ATTRIBUTES.each { |attr| instance_variable_set("@#{attr}", '') }
BOOLEAN_ATTRIBUTES_OF_TRUE.each { |attr| instance_variable_set("@#{attr}", true) }
BOOLEAN_ATTRIBUTES_OF_FALSE.each { |attr| instance_variable_set("@#{attr}", false) }
end end
def get_action_chain def get_action_chain
......
module IGeTui module IGeTui
class TransmissionTemplate < BaseTemplate class TransmissionTemplate < BaseTemplate
def initialize def initialize
@transmission_type = 0
@transmission_content = ''
super super
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment