Module: Mutils::Serialization::Results::Relations
- Included in:
- SerializationResults
- Defined in:
- lib/mutils/serialization/results/relations.rb
Overview
Module Relations
Instance Method Summary collapse
- #hash_relationship(key, s_options, result_hash) ⇒ Object
- #hash_relationships(relationships_array, result_hash) ⇒ Object
Instance Method Details
#hash_relationship(key, s_options, result_hash) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/mutils/serialization/results/relations.rb', line 17 def hash_relationship(key, , result_hash) object = scope.send(key) name = [:label] Lib::Helper.instance.collection?(object) && (name = Lib::Helper.instance.pluralize(name)) name = name.to_sym check_if_included(, key) && (result_hash[name] = Lib::Helper.instance.constantize([:serializer]).new(object).to_h) end |
#hash_relationships(relationships_array, result_hash) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/mutils/serialization/results/relations.rb', line 10 def hash_relationships(relationships_array, result_hash) relationships = relationships_array&.compact relationships&.each do |key, | hash_relationship(key, , result_hash) end end |