Class: SmoothOperator::Attributes::Dirty
- Inherits:
-
Object
- Object
- 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.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#unknown_hash_class ⇒ Object
readonly
Returns the value of attribute unknown_hash_class.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(name, value, type, unknown_hash_class) ⇒ Dirty
constructor
A new instance of Dirty.
- #set_value(new_value) ⇒ Object
- #was ⇒ Object
Constructor Details
#initialize(name, value, type, unknown_hash_class) ⇒ Dirty
10 11 12 13 14 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 10 def initialize(name, value, type, unknown_hash_class) @original_name, @original_value, @type, @unknown_hash_class = name, value, type, unknown_hash_class @first_value = set_value(value) end |
Instance Attribute Details
#first_value ⇒ Object (readonly)
Returns the value of attribute first_value.
8 9 10 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 8 def first_value @first_value end |
#original_name ⇒ Object (readonly)
Returns the value of attribute original_name.
8 9 10 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 8 def original_name @original_name end |
#original_value ⇒ Object (readonly)
Returns the value of attribute original_value.
8 9 10 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 8 def original_value @original_value end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 8 def type @type end |
#unknown_hash_class ⇒ Object (readonly)
Returns the value of attribute unknown_hash_class.
8 9 10 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 8 def unknown_hash_class @unknown_hash_class end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 8 def value @value end |
Instance Method Details
#changed? ⇒ Boolean
20 21 22 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 20 def changed? @first_value != @value end |
#set_value(new_value) ⇒ Object
16 17 18 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 16 def set_value(new_value) @value = TypeConverter.cast_to_type(original_name, new_value, type, self.class, unknown_hash_class) end |
#was ⇒ Object
24 25 26 |
# File 'lib/smooth_operator/attributes/dirty.rb', line 24 def was @first_value end |