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.2.1"
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.
90 91 92 93 94 95 |
# File 'lib/moribus.rb', line 90 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.
67 68 69 70 71 |
# File 'lib/moribus.rb', line 67 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.
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/moribus.rb', line 76 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) @changed_attributes = {} else restore_before_to_new_record_values end @new_record = false true end |
#updated_as_aggregated? ⇒ Boolean
Helper method used by has_aggregated (in fact, belongs_to) association during autosave.
99 100 101 |
# File 'lib/moribus.rb', line 99 def updated_as_aggregated? !!@updated_as_aggregated end |