Class: SmoothOperator::Attributes::Dirty
- Defined in:
- lib/smooth_operator/attributes/dirty.rb
Instance Attribute Summary collapse
-
#first_value ⇒ Object
readonly
Returns the value of attribute first_value.
-
#original_name ⇒ Object
readonly
Returns the value of attribute original_name.
-
#original_value ⇒ Object
readonly
Returns the value of attribute original_value.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(name, value, parent_object) ⇒ Dirty
constructor
A new instance of Dirty.
- #set_value(new_value, parent_object) ⇒ Object
- #was ⇒ Object
Constructor Details
#initialize(name, value, parent_object) ⇒ Dirty
Returns a new instance of Dirty.
8 9 10 11 12 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 8 def initialize(name, value, parent_object) @original_name, @original_value = name, value @first_value = set_value(value, parent_object) end |
Instance Attribute Details
#first_value ⇒ Object (readonly)
Returns the value of attribute first_value.
6 7 8 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 6 def first_value @first_value end |
#original_name ⇒ Object (readonly)
Returns the value of attribute original_name.
6 7 8 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 6 def original_name @original_name end |
#original_value ⇒ Object (readonly)
Returns the value of attribute original_value.
6 7 8 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 6 def original_value @original_value end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 6 def value @value end |
Instance Method Details
#changed? ⇒ Boolean
18 19 20 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 18 def changed? @first_value != @value end |
#set_value(new_value, parent_object) ⇒ Object
14 15 16 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 14 def set_value(new_value, parent_object) @value = cast_to_type(original_name, new_value, parent_object) end |
#was ⇒ Object
22 23 24 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 22 def was @first_value end |