Sha256: a4ddca79869f49e71013c48ab12ddf370e12f9bf48ec4e5594596fda1f7c0a9d

Contents?: true

Size: 521 Bytes

Versions: 11

Compression:

Stored size: 521 Bytes

Contents

module Conglomerate
  class Template
    include Conglomerate::Particle

    array :data, :contains => Datum

    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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
conglomerate-0.16.0 lib/conglomerate/template.rb
conglomerate-0.15.0 lib/conglomerate/template.rb
conglomerate-0.14.0 lib/conglomerate/template.rb
conglomerate-0.13.0 lib/conglomerate/template.rb
conglomerate-0.12.1 lib/conglomerate/template.rb
conglomerate-0.12.0 lib/conglomerate/template.rb
conglomerate-0.11.1 lib/conglomerate/template.rb
conglomerate-0.11.0 lib/conglomerate/template.rb
conglomerate-0.10.0 lib/conglomerate/template.rb
conglomerate-0.9.0 lib/conglomerate/template.rb
conglomerate-0.8.1 lib/conglomerate/template.rb