Methods
Instance Public methods
reference_from_sym(sym)
Link
FIXME: Duplicated in params.rb
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/reference.rb 23 def reference_from_sym(sym) 24 ref = try(sym) 25 return unless ref 26 27 # This is mostly how serializable_hash does it 28 # Get the first object 29 return ref.first if ref.respond_to?(:to_ary) 30 31 ref 32 end
reference_to_sym(reference)
Link
FIXME: Duplicated in params.rb
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/reference.rb 18 def reference_to_sym(reference) 19 reference.is_a?(Hash) ? reference.keys.first : reference 20 end
references_for_serialization()
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/reference.rb 12 def references_for_serialization 13 serialize_references(references) 14 end
serialize_references(references)
Link
Source: show
# File rhino/rhino/lib/rhino/resource/active_model_extension/reference.rb 34 def serialize_references(references) 35 hash = {} 36 references.each do |ref_item| 37 sym = reference_to_sym(ref_item) 38 39 hash[sym] = {} 40 hash[sym][:methods] = :display_name 41 hash[sym][:include] = serialize_references(ref_item[sym]) if ref_item.is_a?(Hash) 42 end.flatten.compact 43 44 hash 45 end