module Kind::Result::Abstract

Public Instance Methods

failed?() click to toggle source
# File lib/kind/result/abstract.rb, line 9
def failed?
  failure?
end
failure?() click to toggle source
# File lib/kind/result/abstract.rb, line 5
def failure?
  false
end
on(&block) click to toggle source
# File lib/kind/result/abstract.rb, line 21
def on(&block)
  raise NotImplementedError
end
on_failure(types = Undefined, matcher = Undefined) click to toggle source
# File lib/kind/result/abstract.rb, line 29
def on_failure(types = Undefined, matcher = Undefined)
  raise NotImplementedError
end
on_success(types = Undefined, matcher = Undefined) click to toggle source
# File lib/kind/result/abstract.rb, line 25
def on_success(types = Undefined, matcher = Undefined)
  raise NotImplementedError
end
result?(types, matcher) click to toggle source
# File lib/kind/result/abstract.rb, line 33
def result?(types, matcher)
  undef_t = Undefined == (t = types)
  undef_m = Undefined == (m = matcher)

  return true if undef_t && undef_m

  if !undef_t && undef_m && !(Array === types || Symbol === types)
    m, t = types, matcher

    undef_m, undef_t = false, true
  end

  is_type = undef_t || (::Array === t ? t.empty? || t.include?(type) : t == type)
  is_type && (undef_m || m === value)
end
succeeded?() click to toggle source
# File lib/kind/result/abstract.rb, line 17
def succeeded?
  success?
end
success?() click to toggle source
# File lib/kind/result/abstract.rb, line 13
def success?
  false
end
to_ary() click to toggle source
# File lib/kind/result/abstract.rb, line 49
def to_ary
  [type, value]
end