Class: Undestroy::Config::Field
- Inherits:
-
Object
- Object
- Undestroy::Config::Field
- Defined in:
- lib/undestroy/config/field.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#raw_value ⇒ Object
Returns the value of attribute raw_value.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #<=>(b) ⇒ Object
-
#initialize(name, type, value = nil, &block) ⇒ Field
constructor
A new instance of Field.
- #value(*args) ⇒ Object
Constructor Details
#initialize(name, type, value = nil, &block) ⇒ Field
Returns a new instance of Field.
9 10 11 12 13 |
# File 'lib/undestroy/config/field.rb', line 9 def initialize(name, type, value=nil, &block) self.name = name self.type = type self.raw_value = block || value || raise(ArgumentError, "Must pass a value or block") end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/undestroy/config/field.rb', line 3 def name @name end |
#raw_value ⇒ Object
Returns the value of attribute raw_value.
3 4 5 |
# File 'lib/undestroy/config/field.rb', line 3 def raw_value @raw_value end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/undestroy/config/field.rb', line 3 def type @type end |
Instance Method Details
#<=>(b) ⇒ Object
5 6 7 |
# File 'lib/undestroy/config/field.rb', line 5 def <=>(b) name.to_s <=> b.name.to_s end |
#value(*args) ⇒ Object
15 16 17 |
# File 'lib/undestroy/config/field.rb', line 15 def value(*args) raw_value.is_a?(Proc) ? raw_value.call(*args) : raw_value end |