Class: Tabulard::Types::Scalars::BoolsyCast
- Inherits:
-
Object
- Object
- Tabulard::Types::Scalars::BoolsyCast
- Defined in:
- lib/tabulard/types/scalars/boolsy_cast.rb
Instance Method Summary collapse
- #call(value, _messenger) ⇒ Object
-
#initialize(truthy: TRUTHY, falsy: FALSY) ⇒ BoolsyCast
constructor
A new instance of BoolsyCast.
Constructor Details
#initialize(truthy: TRUTHY, falsy: FALSY) ⇒ BoolsyCast
Returns a new instance of BoolsyCast.
16 17 18 19 |
# File 'lib/tabulard/types/scalars/boolsy_cast.rb', line 16 def initialize(truthy: TRUTHY, falsy: FALSY, **) @truthy = truthy @falsy = falsy end |
Instance Method Details
#call(value, _messenger) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tabulard/types/scalars/boolsy_cast.rb', line 21 def call(value, _messenger) if @truthy.include?(value) true elsif @falsy.include?(value) false else throw :failure, Messaging::Messages::MustBeBoolsy.new( code_data: { value: value.inspect } ) end end |