Sha256: 93e1f9aff089ac31e5b0448eab81ecb2aebc711cd2860e46214eab60c6e861f8

Contents?: true

Size: 452 Bytes

Versions: 9

Compression:

Stored size: 452 Bytes

Contents

# frozen_string_literal: true

# From ActiveSupport
unless Object.method_defined? :try
  class Object
    def try(*a, &b)
      if a.empty? || respond_to?(a.first)
        if a.empty? && block_given?
          if b.arity == 0
            instance_eval(&b)
          else
            yield self
          end
        else
          public_send(*a, &b)
        end
      end
    end
  end

  class NilClass
    def try(*args)
      nil
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/backports-3.12.0/lib/backports/rails/kernel.rb
backports-3.16.0 lib/backports/rails/kernel.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/backports-3.15.0/lib/backports/rails/kernel.rb
backports-3.15.0 lib/backports/rails/kernel.rb
backports-3.14.0 lib/backports/rails/kernel.rb
backports-3.13.0 lib/backports/rails/kernel.rb
backports-3.12.0 lib/backports/rails/kernel.rb
backports-3.11.4 lib/backports/rails/kernel.rb
backports-3.11.3 lib/backports/rails/kernel.rb