Module: Moribus
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern
- Defined in:
- lib/moribus.rb,
lib/moribus/macros.rb,
lib/moribus/version.rb,
lib/moribus/extensions.rb,
lib/moribus/tracked_behavior.rb,
lib/moribus/alias_association.rb,
lib/moribus/aggregated_behavior.rb,
lib/moribus/aggregated_cache_behavior.rb,
lib/moribus/extensions/delegate_associated.rb,
lib/moribus/extensions/has_current_extension.rb,
lib/moribus/extensions/has_aggregated_extension.rb
Overview
:nodoc:
Defined Under Namespace
Modules: AggregatedBehavior, AggregatedCacheBehavior, AliasAssociation, ClassMethods, Extensions, Macros, TrackedBehavior
Constant Summary collapse
- VERSION =
:nodoc:
"0.11.0"
Instance Method Summary collapse
-
#set_parent ⇒ Object
Stores original record id for tracking purposes.
-
#to_new_record! ⇒ Object
Marks
selfas a new record. -
#to_persistent!(existing = nil) ⇒ Object
Marks
selfas persistent record. -
#updated_as_aggregated? ⇒ Boolean
Helper method used by has_aggregated (in fact, belongs_to) association during autosave.
Instance Method Details
#set_parent ⇒ Object
Stores original record id for tracking purposes.
112 113 114 115 116 117 |
# File 'lib/moribus.rb', line 112 def set_parent tbc = self.class.preceding_key_column if tbc && self.respond_to?(tbc) write_attribute(tbc, @_before_to_new_record_values[:id]) end end |
#to_new_record! ⇒ Object
Marks self as a new record. Sets id attribute to nil, but memorizes the old value in case of exception.
85 86 87 88 89 |
# File 'lib/moribus.rb', line 85 def to_new_record! store_before_to_new_record_values reset_persistence_values @new_record = true end |
#to_persistent!(existing = nil) ⇒ Object
Marks self as persistent record. If another record is passed, uses its persistence attributes (id, timestamps). If nil is passed as an argument, marks self as persisted record and sets id to memorized value.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/moribus.rb', line 94 def to_persistent!(existing = nil) if existing self.id = existing.id self.created_at = existing.created_at if respond_to?(:created_at) self.updated_at = existing.updated_at if respond_to?(:updated_at) clear_changes_information else restore_before_to_new_record_values clear_attribute_change(:created_at) if respond_to?(:created_at) clear_attribute_change(:updated_at) if respond_to?(:updated_at) end @new_record = false true end |
#updated_as_aggregated? ⇒ Boolean
Helper method used by has_aggregated (in fact, belongs_to) association during autosave.
121 122 123 |
# File 'lib/moribus.rb', line 121 def updated_as_aggregated? !!@updated_as_aggregated end |