Class: Extant::Attribute
- Inherits:
-
Object
- Object
- Extant::Attribute
- Defined in:
- lib/extant/attribute.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pre_coerce_value ⇒ Object
readonly
Returns the value of attribute pre_coerce_value.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #coerced? ⇒ Boolean
- #coercer_name ⇒ Object
- #has_changed? ⇒ Boolean
-
#initialize(name, value, definition) ⇒ Attribute
constructor
A new instance of Attribute.
- #inspect ⇒ Object
- #set? ⇒ Boolean
- #unset? ⇒ Boolean
Constructor Details
#initialize(name, value, definition) ⇒ Attribute
Returns a new instance of Attribute.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/extant/attribute.rb', line 5 def initialize(name, value, definition) self.name = name self.has_been_coereced = false self.definition = definition if UnsetValue == value @value = nil self.is_unset = true else set_value(value) end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/extant/attribute.rb', line 3 def name @name end |
#pre_coerce_value ⇒ Object
Returns the value of attribute pre_coerce_value.
3 4 5 |
# File 'lib/extant/attribute.rb', line 3 def pre_coerce_value @pre_coerce_value end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/extant/attribute.rb', line 3 def value @value end |
Instance Method Details
#coerced? ⇒ Boolean
23 24 25 |
# File 'lib/extant/attribute.rb', line 23 def coerced? !!has_been_coereced end |
#coercer_name ⇒ Object
39 40 41 |
# File 'lib/extant/attribute.rb', line 39 def coercer_name coercer_class.try(:coercer_name) end |
#has_changed? ⇒ Boolean
27 28 29 |
# File 'lib/extant/attribute.rb', line 27 def has_changed? !!value_has_changed end |
#inspect ⇒ Object
43 44 45 |
# File 'lib/extant/attribute.rb', line 43 def inspect "<Extant::Attribute:#{self.object_id} Name: :#{name} Value: #{value.inspect}>" end |
#set? ⇒ Boolean
35 36 37 |
# File 'lib/extant/attribute.rb', line 35 def set? !is_unset end |
#unset? ⇒ Boolean
31 32 33 |
# File 'lib/extant/attribute.rb', line 31 def unset? !set? end |