Class: SmoothOperator::Attributes::Dirty

Inherits:
Base
  • Object
show all
Defined in:
lib/smooth_operator/attributes/dirty.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_valueObject (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_nameObject (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_valueObject (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

#valueObject (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

Returns:

  • (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

#wasObject



22
23
24
# File 'lib/smooth_operator/attributes/dirty.rb', line 22

def was
  @first_value
end