Module: SerializeWith::MongoidSerializationOverrides

Defined in:
lib/serialize_with.rb

Overview

This overrides the serialize_relations method in Mongoid::Serialization to prevent it from passing serialization options through to relations.

Instance Method Summary collapse

Instance Method Details

#relation_names(inclusions) ⇒ Object



77
78
79
# File 'lib/serialize_with.rb', line 77

def relation_names(inclusions)
  inclusions.is_a?(Hash) ? inclusions.keys : Array.wrap(inclusions)
end

#serialize_relations(attributes = {}, options = {}) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/serialize_with.rb', line 66

def serialize_relations(attributes = {}, options = {})
  inclusions = options[:include]
  relation_names(inclusions).each do |name|
     = relations[name.to_s]
    if  && relation = send(.name)
      attributes[.name.to_s] =
        relation.serializable_hash #(relation_options(inclusions, options, name))
    end
  end
end