Module: Kind::Result::Abstract
- Included in:
- Monad
- Defined in:
- lib/kind/result/abstract.rb
Instance Method Summary collapse
- #failed? ⇒ Boolean
- #failure? ⇒ Boolean
- #on(&block) ⇒ Object
- #on_failure(types = Undefined, matcher = Undefined) ⇒ Object
- #on_success(types = Undefined, matcher = Undefined) ⇒ Object
- #result?(types, matcher) ⇒ Boolean
- #succeeded? ⇒ Boolean
- #success? ⇒ Boolean
- #to_ary ⇒ Object
Instance Method Details
#on(&block) ⇒ Object
21 22 23 |
# File 'lib/kind/result/abstract.rb', line 21 def on(&block) raise NotImplementedError end |
#on_failure(types = Undefined, matcher = Undefined) ⇒ Object
29 30 31 |
# File 'lib/kind/result/abstract.rb', line 29 def on_failure(types = Undefined, matcher = Undefined) raise NotImplementedError end |
#on_success(types = Undefined, matcher = Undefined) ⇒ Object
25 26 27 |
# File 'lib/kind/result/abstract.rb', line 25 def on_success(types = Undefined, matcher = Undefined) raise NotImplementedError end |
#result?(types, matcher) ⇒ Boolean
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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? ⇒ Boolean
17 18 19 |
# File 'lib/kind/result/abstract.rb', line 17 def succeeded? success? end |
#to_ary ⇒ Object
49 50 51 |
# File 'lib/kind/result/abstract.rb', line 49 def to_ary [type, value] end |