Class: Sheetah::Types::Scalars::BoolsyCast
- Inherits:
-
Object
- Object
- Sheetah::Types::Scalars::BoolsyCast
- Defined in:
- lib/sheetah/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.
15 16 17 18 |
# File 'lib/sheetah/types/scalars/boolsy_cast.rb', line 15 def initialize(truthy: TRUTHY, falsy: FALSY, **) @truthy = truthy @falsy = falsy end |
Instance Method Details
#call(value, messenger) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sheetah/types/scalars/boolsy_cast.rb', line 20 def call(value, messenger) if @truthy.include?(value) true elsif @falsy.include?(value) false else messenger.error("must_be_boolsy", value: value.inspect) throw :failure end end |