Class: PollEverywhere::Serializable::Property::Value
- Inherits:
-
Object
- Object
- PollEverywhere::Serializable::Property::Value
- Defined in:
- lib/polleverywhere/serializable.rb
Overview
Contains the value of the property, runs validations, and tracks property changes
Defined Under Namespace
Classes: Set
Instance Attribute Summary collapse
-
#current ⇒ Object
(also: #is)
Returns the value of attribute current.
-
#original ⇒ Object
(also: #was)
readonly
Returns the value of attribute original.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
Instance Method Summary collapse
-
#changed? ⇒ Boolean
Detect if the values have changed since we last updated them.
-
#changes ⇒ Object
The original and current state of the value if it changed.
-
#commit ⇒ Object
Commit the values if they’re valid.
-
#initialize(property) ⇒ Value
constructor
A new instance of Value.
Constructor Details
#initialize(property) ⇒ Value
Returns a new instance of Value.
107 108 109 |
# File 'lib/polleverywhere/serializable.rb', line 107 def initialize(property) @property = property end |
Instance Attribute Details
#current ⇒ Object Also known as: is
Returns the value of attribute current.
102 103 104 |
# File 'lib/polleverywhere/serializable.rb', line 102 def current @current end |
#original ⇒ Object (readonly) Also known as: was
Returns the value of attribute original.
101 102 103 |
# File 'lib/polleverywhere/serializable.rb', line 101 def original @original end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
101 102 103 |
# File 'lib/polleverywhere/serializable.rb', line 101 def property @property end |
Instance Method Details
#changed? ⇒ Boolean
Detect if the values have changed since we last updated them
112 113 114 |
# File 'lib/polleverywhere/serializable.rb', line 112 def changed? original != current end |
#changes ⇒ Object
The original and current state of the value if it changed.
117 118 119 |
# File 'lib/polleverywhere/serializable.rb', line 117 def changes [original, current] if changed? end |
#commit ⇒ Object
Commit the values if they’re valid
122 123 124 |
# File 'lib/polleverywhere/serializable.rb', line 122 def commit @original = @current end |