Class: RailsSettingsUi::ValueTypes::Base
- Inherits:
-
Object
- Object
- RailsSettingsUi::ValueTypes::Base
- Defined in:
- lib/rails-settings-ui/value_types/base.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #cast ⇒ Object
-
#initialize(value) ⇒ Base
constructor
A new instance of Base.
- #valid? ⇒ Boolean
- #value_numeric? ⇒ Boolean
Constructor Details
#initialize(value) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 |
# File 'lib/rails-settings-ui/value_types/base.rb', line 6 def initialize(value) self.value = value self.errors = [] validate end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/rails-settings-ui/value_types/base.rb', line 4 def errors @errors end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/rails-settings-ui/value_types/base.rb', line 4 def value @value end |
Instance Method Details
#cast ⇒ Object
12 13 14 |
# File 'lib/rails-settings-ui/value_types/base.rb', line 12 def cast raise NotImplementedError end |
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/rails-settings-ui/value_types/base.rb', line 16 def valid? !errors.any? end |
#value_numeric? ⇒ Boolean
20 21 22 |
# File 'lib/rails-settings-ui/value_types/base.rb', line 20 def value_numeric? !value.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/).nil? end |