Class: Thy::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/thy/type.rb

Instance Method Summary collapse

Constructor Details

#initialize(&checker) ⇒ Type

Returns a new instance of Type.



5
6
7
# File 'lib/thy/type.rb', line 5

def initialize(&checker)
  @checker = checker
end

Instance Method Details

#check(value) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/thy/type.rb', line 9

def check(value)
  check_result = @checker.call(value)

  return Result::Success if check_result == true
  return Result::Failure.new('No message provided') if check_result == false

  check_result
end