Class: Virtus::DirtyAttribute::Session
- Defined in:
- lib/virtus/dirty_attribute/session.rb
Instance Attribute Summary collapse
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #attribute_clean!(name) ⇒ Object
- #clean! ⇒ Object
- #dirty!(name, value) ⇒ Object
- #dirty?(name = nil) ⇒ Boolean
- #dirty_attributes ⇒ Object
-
#initialize(subject) ⇒ Session
constructor
A new instance of Session.
- #original_attributes ⇒ Object
Constructor Details
#initialize(subject) ⇒ Session
Returns a new instance of Session.
7 8 9 |
# File 'lib/virtus/dirty_attribute/session.rb', line 7 def initialize(subject) @subject = subject end |
Instance Attribute Details
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
5 6 7 |
# File 'lib/virtus/dirty_attribute/session.rb', line 5 def subject @subject end |
Instance Method Details
#attribute_clean!(name) ⇒ Object
23 24 25 26 |
# File 'lib/virtus/dirty_attribute/session.rb', line 23 def attribute_clean!(name) dirty_attributes.delete name original_attributes.delete name end |
#clean! ⇒ Object
32 33 34 35 |
# File 'lib/virtus/dirty_attribute/session.rb', line 32 def clean! original_attributes.clear dirty_attributes.clear end |
#dirty!(name, value) ⇒ Object
19 20 21 |
# File 'lib/virtus/dirty_attribute/session.rb', line 19 def dirty!(name, value) dirty_attributes[name] = value end |
#dirty?(name = nil) ⇒ Boolean
28 29 30 |
# File 'lib/virtus/dirty_attribute/session.rb', line 28 def dirty?(name = nil) name ? dirty_attributes.key?(name) : dirty_attributes.any? end |
#dirty_attributes ⇒ Object
15 16 17 |
# File 'lib/virtus/dirty_attribute/session.rb', line 15 def dirty_attributes @_dirty_attributes ||= {} end |
#original_attributes ⇒ Object
11 12 13 |
# File 'lib/virtus/dirty_attribute/session.rb', line 11 def original_attributes @_original_attributes ||= get_original_attributes(subject).dup end |