class Canal::Context

Public Class Methods

new() click to toggle source
# File lib/canal.rb, line 5
def initialize
  @functions = []
end

Public Instance Methods

call(object) click to toggle source
# File lib/canal.rb, line 17
def call(object)
  @functions.reduce(object) do |object, function|
    name, args, block = function
    object.send(name, *args, &block)
  end
end
method_missing(name, *args, &block) click to toggle source
# File lib/canal.rb, line 9
def method_missing(name, *args, &block)
  functions = @functions
  Canal::Context.new.instance_eval {
    @functions = functions + [[name, args, block]]
    self
  }
end
to_proc() click to toggle source
# File lib/canal.rb, line 24
def to_proc
  ->(object) { call(object) }
end