class Thy::Types::Option

Public Class Methods

new(type) click to toggle source
# File lib/thy/types/option.rb, line 6
def initialize(type)
  @type = type
end

Public Instance Methods

check(value) click to toggle source
# File lib/thy/types/option.rb, line 10
def check(value)
  return Result::Success if value.nil?

  if @type.check(value).success?
    Result::Success
  else
    Result::Failure.new("Expected #{value.inspect} to be of type #{@type.inspect}")
  end
end