Class: Conglomerate::Template

Inherits:
Object
  • Object
show all
Includes:
Particle
Defined in:
lib/conglomerate/template.rb

Instance Method Summary collapse

Methods included from Particle

included, #initialize

Instance Method Details

#build(attrs = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/conglomerate/template.rb', line 7

def build(attrs = {})
  attrs = Hash[attrs.map{ |k, v| [k.to_sym, v] }]
  template = Template.new

  data.each do |datum|
    if attrs.has_key?(datum.name.to_sym)
      template.data << Datum.new(
        :name => datum.name,
        :value => attrs[datum.name.to_sym]
      )
    end
  end

  { "template" => Conglomerate.serialize(template) }
end