Sha256: abdda79c96e9a2db90d411e86db7ee7325187f2da2b97523cfd82551323818f0
Contents?: true
Size: 984 Bytes
Versions: 6
Compression:
Stored size: 984 Bytes
Contents
module Compositor class Composite < Compositor::Base attr_accessor :collection, :renderer def initialize(view_context, args = {}) super @collection_set = true if args.has_key?(:collection) self.collection ||= [] end def to_hash with_root_element do renderer.new(self, collection).render end end def composite? true end def dsl(dsl, &block) original_generator = dsl.generator dsl.generator = self if self.collection && @collection_set && block # reset collection, we'll be mapping it via a block unmapped_collection = collection self.collection = [] unmapped_collection.each do |object| dsl.instance_exec(object, &block) end elsif block dsl.instance_eval &block end dsl.generator = original_generator if original_generator dsl.generator.collection << self if dsl.generator != self end end end
Version data entries
6 entries across 6 versions & 1 rubygems