Module: ToProc

Defined in:
lib/to_proc.rb,
lib/to_proc/key.rb,
lib/to_proc/try.rb,
lib/to_proc/two.rb,
lib/to_proc/value.rb,
lib/to_proc/refine.rb,
lib/to_proc/refine/array.rb,
lib/to_proc/refine/class.rb,
lib/to_proc/refine/object.rb

Defined Under Namespace

Modules: Refine

Constant Summary collapse

Key =
-> *array do
  -> pair { array.to_proc.call pair[0] }
end
Try =
-> process do
  -> input do
    begin
      output = process[input]
      output.nil? ? input : output
    rescue
      input
    end
  end
end
Two =
-> method do
  -> receiver, argument { receiver.send method, argument }
end
Value =
-> *array do
  -> pair { array.to_proc.call pair[1] }
end

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/to_proc.rb', line 2

def self.[] name
  Module.new do
    define_method :to_proc do
      method(name).to_proc
    end
  end
end