Class: Plivo::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, language: nil, components: nil) ⇒ Template

Returns a new instance of Template.



8
9
10
11
12
# File 'lib/plivo/template.rb', line 8

def initialize(name: nil, language: nil, components: nil)
  @name = name
  @language = language
  @components = components
end

Instance Attribute Details

#componentsObject

Returns the value of attribute components.



6
7
8
# File 'lib/plivo/template.rb', line 6

def components
  @components
end

#languageObject

Returns the value of attribute language.



6
7
8
# File 'lib/plivo/template.rb', line 6

def language
  @language
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/plivo/template.rb', line 6

def name
  @name
end

Instance Method Details

#to_hashObject



14
15
16
17
18
19
20
# File 'lib/plivo/template.rb', line 14

def to_hash
  {
    name: @name,
    language: @language,
    components: @components&.map(&:to_hash)&.reject { |h| h.values.all?(&:nil?) }
  }.reject { |_, v| v.nil? }
end