Class: Rod::ReferenceUpdater::SingularUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/rod/reference_updater.rb

Overview

Singular reference updater holds the rod_id and class_id of the object that has to be updated and the name of the property of the reference to be updated.

Instance Method Summary collapse

Constructor Details

#initialize(database, rod_id, class_id, property) ⇒ SingularUpdater

Returns a new instance of SingularUpdater.



20
21
22
23
24
25
# File 'lib/rod/reference_updater.rb', line 20

def initialize(database,rod_id,class_id,property)
  @database = database
  @rod_id = rod_id
  @class_id = class_id
  @property = property
end

Instance Method Details

#update(object) ⇒ Object

Updates the id of the referenced object.



28
29
30
31
# File 'lib/rod/reference_updater.rb', line 28

def update(object)
  referee = Model.get_class(@class_id).find_by_rod_id(@rod_id)
  referee.update_singular_association(@property,object)
end