Class: FamilyappSdk::Components::Templates

Inherits:
Object
  • Object
show all
Defined in:
lib/familyapp_sdk/components/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, elements: nil, buttons: nil) ⇒ Templates

Returns a new instance of Templates.



6
7
8
9
10
# File 'lib/familyapp_sdk/components/template.rb', line 6

def initialize(type:, elements: nil, buttons: nil)
  @template_type = type
  @elements_attributes      = build_attributes(elements)
  @buttons_attributes       = build_attributes(buttons)
end

Instance Attribute Details

#buttons_attributesObject

Returns the value of attribute buttons_attributes.



4
5
6
# File 'lib/familyapp_sdk/components/template.rb', line 4

def buttons_attributes
  @buttons_attributes
end

#elements_attributesObject

Returns the value of attribute elements_attributes.



4
5
6
# File 'lib/familyapp_sdk/components/template.rb', line 4

def elements_attributes
  @elements_attributes
end

#template_typeObject

Returns the value of attribute template_type.



4
5
6
# File 'lib/familyapp_sdk/components/template.rb', line 4

def template_type
  @template_type
end

Instance Method Details

#buildObject



12
13
14
# File 'lib/familyapp_sdk/components/template.rb', line 12

def build
  instance_values.delete_if { |_attribute, value| value.nil? }
end

#build_attributes(attributes) ⇒ Object



16
17
18
# File 'lib/familyapp_sdk/components/template.rb', line 16

def build_attributes(attributes)
  attributes.map(&:build) if attributes.present?
end