Class: LiquidComponent::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid-component/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ Metadata

Returns a new instance of Metadata.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/liquid-component/metadata.rb', line 7

def initialize()
   = .with_indifferent_access

  self.name = [:name]
  self.description = [:description]
  self.variables = Variable.parse([:variables])

  .delete(:name)
  .delete(:description)
  .delete(:variables)

  self.additional = 
end

Instance Attribute Details

#additionalObject

Returns the value of attribute additional.



5
6
7
# File 'lib/liquid-component/metadata.rb', line 5

def additional
  @additional
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/liquid-component/metadata.rb', line 5

def description
  @description
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/liquid-component/metadata.rb', line 5

def name
  @name
end

#variablesObject

Returns the value of attribute variables.



5
6
7
# File 'lib/liquid-component/metadata.rb', line 5

def variables
  @variables
end

Instance Method Details

#to_hObject



21
22
23
24
25
26
27
28
29
# File 'lib/liquid-component/metadata.rb', line 21

def to_h
  h = {}
  h[:name] = name if name
  h[:description] = description if description
  h[:variables] = variables.map(&:to_h)
  h[:additional] = additional

  h
end