Module: Virtus::Dirty
- Defined in:
- lib/virtus/dirty.rb,
lib/virtus/dirty/session.rb,
lib/virtus/dirty/version.rb
Overview
Dirty Tracking
Dirty Tracking is an optional module that you include only if you need it.
Defined Under Namespace
Modules: Attribute Classes: Session
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
-
.included(base) ⇒ Object
private
Extends a class with Dirty::Attribute module.
Instance Method Summary collapse
-
#attribute_dirty!(name, value) ⇒ Object
Explicitly sets an attribute as dirty.
-
#attribute_dirty?(name) ⇒ TrueClass, FalseClass
Returns if an attribute with the given name is dirty.
-
#dirty? ⇒ TrueClass, FalseClass
Returns if an object is dirty.
-
#dirty_attributes ⇒ Hash
Returns all dirty attributes.
-
#dirty_session ⇒ Virtus::Dirty::Session
private
Returns the current dirty tracking session.
-
#original_attributes ⇒ Hash
Returns original attributes.
Class Method Details
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extends a class with Dirty::Attribute module
14 15 16 |
# File 'lib/virtus/dirty.rb', line 14 def self.included(base) base.extend(Dirty::Attribute) end |
Instance Method Details
#attribute_dirty!(name, value) ⇒ Object
Explicitly sets an attribute as dirty.
47 48 49 |
# File 'lib/virtus/dirty.rb', line 47 def attribute_dirty!(name, value) dirty_session.dirty!(name, value) end |
#attribute_dirty?(name) ⇒ TrueClass, FalseClass
Returns if an attribute with the given name is dirty.
34 35 36 |
# File 'lib/virtus/dirty.rb', line 34 def attribute_dirty?(name) dirty_session.dirty?(name) end |
#dirty? ⇒ TrueClass, FalseClass
Returns if an object is dirty
23 24 25 |
# File 'lib/virtus/dirty.rb', line 23 def dirty? dirty_session.dirty? end |
#dirty_attributes ⇒ Hash
Returns all dirty attributes
57 58 59 |
# File 'lib/virtus/dirty.rb', line 57 def dirty_attributes dirty_session.dirty_attributes end |
#dirty_session ⇒ Virtus::Dirty::Session
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the current dirty tracking session
76 77 78 |
# File 'lib/virtus/dirty.rb', line 76 def dirty_session @_dirty_session ||= Session.new(self) end |
#original_attributes ⇒ Hash
Returns original attributes
67 68 69 |
# File 'lib/virtus/dirty.rb', line 67 def original_attributes dirty_session.original_attributes end |