Module: MassiveRecord::ORM::Relations::Interface

Extended by:
ActiveSupport::Concern
Defined in:
lib/massive_record/orm/relations/interface.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#attributes=(attributes) ⇒ Object



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/massive_record/orm/relations/interface.rb', line 245

def attributes=(attributes)
  attributes_for_relations = {}

  if relations && attributes.is_a?(Hash)
    attributes.stringify_keys!
    relation_names = relations.collect(&:name)

    attributes.delete_if do |attr_name, value|
      attributes_for_relations[attr_name] = value if relation_names.include? attr_name
    end
  end

  super(attributes)
  super(attributes_for_relations)
end

#relation_proxiesObject



262
263
264
# File 'lib/massive_record/orm/relations/interface.rb', line 262

def relation_proxies
  (relations || []).map { || relation_proxy(.name) }
end

#relation_proxies_for_embeddedObject



266
267
268
# File 'lib/massive_record/orm/relations/interface.rb', line 266

def relation_proxies_for_embedded
  (relations || []).select(&:embedded?).map { || relation_proxy(.name) }
end

#reloadObject



240
241
242
243
# File 'lib/massive_record/orm/relations/interface.rb', line 240

def reload
  reset_relation_proxies
  super
end