Module: Representable::Hash::Collection
- Includes:
- Representable::Hash
- Defined in:
- lib/representable/hash/collection.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#create_representation_with(doc, options, format) ⇒ Object
TODO: revise lonely collection and build separate pipeline where we just use Serialize, etc.
- #update_properties_from(doc, options, format) ⇒ Object
Methods included from Representable::Hash
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/representable/hash/collection.rb', line 7 def self.included(base) base.class_eval do include Representable::Hash extend ClassMethods property(:_self, {:collection => true}) end end |
Instance Method Details
#create_representation_with(doc, options, format) ⇒ Object
TODO: revise lonely collection and build separate pipeline where we just use Serialize, etc.
24 25 26 27 28 29 30 31 32 |
# File 'lib/representable/hash/collection.rb', line 24 def create_representation_with(doc, , format) = (**) [:_self] = bin = representable_bindings_for(format, ).first Collect[*bin.default_render_fragment_functions]. (represented, {doc: doc, fragment: represented, options: , binding: bin, represented: represented}) end |
#update_properties_from(doc, options, format) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/representable/hash/collection.rb', line 34 def update_properties_from(doc, , format) = (**) [:_self] = bin = representable_bindings_for(format, ).first value = Collect[*bin.default_parse_fragment_functions]. (doc, fragment: doc, document: doc, options: , binding: bin, represented: represented) represented.replace(value) end |