Sha256: 768c0d2e9f5e82b7eae86b9c6d9f0363b6fb4df0e75fe2e68bb70a2a8ab2382e

Contents?: true

Size: 457 Bytes

Versions: 1

Compression:

Stored size: 457 Bytes

Contents

module ActiveEnumerable
  # @private
  class MethodCaller
    attr_reader :object, :raise_no_method

    def initialize(object, raise_no_method: true)
      @object          = object
      @raise_no_method = raise_no_method
    end

    def call(method)
      if object.is_a? Hash
        object.fetch(method)
      else
        object.public_send(method)
      end
    rescue NoMethodError, KeyError => e
      raise e if raise_no_method
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_enumerable-0.1.1 lib/active_enumerable/method_caller.rb