Module: Kind::Try
Class Method Summary collapse
Instance Method Summary collapse
- #call(object, *input) {|result| ... } ⇒ Object
-
#call!(object, method_name, args = Empty::ARRAY) ⇒ Object
:nodoc.
- #presence(*args, &block) ⇒ Object
Class Method Details
.[](*args) ⇒ Object
31 32 33 34 35 |
# File 'lib/kind/try.rb', line 31 def self.[](*args) method_name = args.shift ->(object) { call!(object, method_name, args) } end |
Instance Method Details
#call(object, *input) {|result| ... } ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/kind/try.rb', line 17 def call(object, *input) args = input.size == 1 && input[0].kind_of?(::Array) ? input[0] : input result = call!(object, args.shift, args) return result unless block_given? yield(result) unless KIND.nil_or_undefined?(result) end |