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.0.1"
Instance Method Summary collapse
-
#set_parent ⇒ Object
Stores original record id for tracking purposes.
-
#to_new_record! ⇒ Object
Marks
self
as a new record. -
#to_persistent!(existing = nil) ⇒ Object
Marks
self
as 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.
88 89 90 91 92 93 |
# File 'lib/moribus.rb', line 88 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.
65 66 67 68 69 |
# File 'lib/moribus.rb', line 65 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.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/moribus.rb', line 74 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.
97 98 99 |
# File 'lib/moribus.rb', line 97 def updated_as_aggregated? !!@updated_as_aggregated end |