Class: Formalism::Form::Coercion::Base
- Inherits:
-
Object
- Object
- Formalism::Form::Coercion::Base
- Defined in:
- lib/formalism/form/coercion/_base.rb
Overview
Base class for coercion
Instance Method Summary collapse
-
#initialize(value) ⇒ Base
constructor
A new instance of Base.
- #result ⇒ Object
Constructor Details
#initialize(value) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/formalism/form/coercion/_base.rb', line 8 def initialize(value, *) @value = value type_name = self.class.name.split('::')[3..].join('::') @type = if ::Object.const_defined?(type_name, false) ::Object.const_get(type_name, false) else type_name end end |
Instance Method Details
#result ⇒ Object
21 22 23 24 25 |
# File 'lib/formalism/form/coercion/_base.rb', line 21 def result return @value unless should_be_coreced? execute end |