Class: Ciesta::Field
- Inherits:
-
Object
- Object
- Ciesta::Field
- Defined in:
- lib/ciesta/field.rb
Constant Summary collapse
- DEFAULT_TYPE =
Ciesta::Types::Any
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, options) ⇒ Field
constructor
A new instance of Field.
- #value ⇒ Object
- #value=(val) ⇒ Object
Constructor Details
#initialize(name, options) ⇒ Field
Returns a new instance of Field.
7 8 9 10 11 |
# File 'lib/ciesta/field.rb', line 7 def initialize(name, ) self.name = name.to_sym self.type = .delete(:type) || DEFAULT_TYPE self.value = .delete(:default) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/ciesta/field.rb', line 5 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/ciesta/field.rb', line 5 def type @type end |
Instance Method Details
#value ⇒ Object
13 14 15 |
# File 'lib/ciesta/field.rb', line 13 def value current_value end |
#value=(val) ⇒ Object
17 18 19 20 21 |
# File 'lib/ciesta/field.rb', line 17 def value=(val) self.current_value = type[val] rescue Dry::Types::ConstraintError raise ViolatesConstraints, "#{current_value} is not a #{type.name}" end |