Sha256: da3d159731861c266fa2f123b4628337564c526cbd8e112827f2f175b9570258

Contents?: true

Size: 420 Bytes

Versions: 9

Compression:

Stored size: 420 Bytes

Contents

module AppInfo
  # Monkey Patch for Object
  module Tryable
    def try(*a, &b)
      try!(*a, &b) if a.empty? || respond_to?(a.first)
    end

    def try!(*a, &b)
      if a.empty? && block_given?
        if b.arity.zero?
          instance_eval(&b)
        else
          yield self
        end
      else
        public_send(*a, &b)
      end
    end
  end
end

# :nodoc:
class Object
  include AppInfo::Tryable
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
app-info-2.0.0.beta3 lib/app_info/core_ext/object/try.rb
app-info-2.0.0.beta1 lib/app_info/core_ext/object/try.rb
app-info-1.1.2 lib/app_info/core_ext/object/try.rb
app-info-1.1.0 lib/app_info/core_ext/object/try.rb
app-info-1.0.5 lib/app_info/core_ext/object/try.rb
app-info-1.0.4 lib/app_info/core_ext/object/try.rb
app-info-1.0.3 lib/app_info/core_ext/object/try.rb
app-info-1.0.2 lib/app_info/core_ext/object/try.rb
app-info-1.0.1 lib/app_info/core_ext/object/try.rb