Sha256: 276c5ba63a0f1ab4eecb81997e683f4938859ca76a164b4951e68865fbc7788d
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
module Representable::Hash module Collection include Representable::Hash def self.included(base) base.class_eval do include Representable::Hash extend ClassMethods property(:_self, {:collection => true}) end end module ClassMethods def items(options={}, &block) collection(:_self, options.merge(:getter => lambda { |*| self }), &block) end end def create_representation_with(doc, options, format) bin = representable_bindings_for(format, options).first Collect[*bin.default_render_fragment_functions]. (represented, {doc: doc, fragment: represented, user_options: options, binding: bin, represented: represented}) end def update_properties_from(doc, options, format) bin = representable_bindings_for(format, options).first value = Collect[*bin.default_parse_fragment_functions]. (doc, fragment: doc, document: doc, user_options: options, binding: bin, represented: represented) represented.replace(value) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
representable-2.4.0.rc3 | lib/representable/hash/collection.rb |
representable-2.4.0.rc2 | lib/representable/hash/collection.rb |
representable-2.4.0.rc1 | lib/representable/hash/collection.rb |