Sha256: e0dbb60dd1795fabd748891149026dbed83debde46c692c4b34514c7150a99f7

Contents?: true

Size: 345 Bytes

Versions: 2

Compression:

Stored size: 345 Bytes

Contents

class Object
  # If object responds to `call` convert into a Proc that takes a key and returns the value of the Hash for that key.
  #
  # @return [Proc]
  def to_proc
    if respond_to?(:call)
      Proc.new do |*args|
        call(*args)
      end
    else
      raise "Don't know how to convert #{self.inspect} into a Proc"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data-functions-0.1.1 lib/data/functions/object.rb
data-functions-0.1.0 lib/data/functions/object.rb