Class: Rabarber::Inputs::Base
- Inherits:
-
Object
- Object
- Rabarber::Inputs::Base
- Defined in:
- lib/rabarber/inputs/base.rb
Direct Known Subclasses
Boolean, Context, DynamicRule, Model, NonEmptyString, Role, Roles, Symbol
Instance Method Summary collapse
-
#initialize(value, optional: false, error: Rabarber::InvalidArgumentError, message: nil) ⇒ Base
constructor
A new instance of Base.
- #process ⇒ Object
Constructor Details
#initialize(value, optional: false, error: Rabarber::InvalidArgumentError, message: nil) ⇒ Base
10 11 12 13 14 15 |
# File 'lib/rabarber/inputs/base.rb', line 10 def initialize(value, optional: false, error: ::InvalidArgumentError, message: nil) @value = value @optional = optional @error = error = end |
Instance Method Details
#process ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rabarber/inputs/base.rb', line 17 def process type_checker = @optional ? type.optional : type type_checker[@value] rescue Dry::Types::CoercionError raise_error end |