Module: ActsAsJoinable::Dirty::InstanceMethods
- Defined in:
- lib/acts_as_joinable/dirty.rb
Instance Method Summary collapse
- #join_attribute_changes(context = nil) ⇒ Object
- #join_attributes_changed(context = nil) ⇒ Object
- #join_attributes_changed?(context = nil) ⇒ Boolean
-
#reload(*args) ⇒ Object
:nodoc:.
- #write_join_attribute(name, value, context = nil) ⇒ Object
Instance Method Details
#join_attribute_changes(context = nil) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/acts_as_joinable/dirty.rb', line 40 def join_attribute_changes(context = nil) join_attributes_changed(context).inject({}) do |changes, join_attribute| changes[join_attribute] = join_attribute_change(join_attribute, context) changes end end |
#join_attributes_changed(context = nil) ⇒ Object
36 37 38 |
# File 'lib/acts_as_joinable/dirty.rb', line 36 def join_attributes_changed(context = nil) join_attributes_changed_context(context).keys end |
#join_attributes_changed?(context = nil) ⇒ Boolean
32 33 34 |
# File 'lib/acts_as_joinable/dirty.rb', line 32 def join_attributes_changed?(context = nil) !join_attributes_changed_context(context).empty? end |
#reload(*args) ⇒ Object
:nodoc:
47 48 49 50 51 52 53 54 |
# File 'lib/acts_as_joinable/dirty.rb', line 47 def reload(*args) #:nodoc: result = super @join_attributes.clear if @join_attributes @join_attributes_changed.clear if @join_attributes_changed result end |
#write_join_attribute(name, value, context = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/acts_as_joinable/dirty.rb', line 13 def write_join_attribute(name, value, context = nil) name = name.to_s assert_valid_join_attribute(name) join_attributes_changed = join_attributes_changed_context(context) if join_attributes_changed.include?(name) old = join_attributes_changed[name] join_attributes_changed.delete(name) unless join_attribute_value_changed?(name, old, value) else old = clone_join_attribute_value(name, context) join_attributes_changed[name] = old if join_attribute_value_changed?(name, old, value) end join_attributes_context(context)[name] = value value end |