class ActiveSupport::Callbacks::Callback
def make_lambda(filter)
All of these objects are converted into a lambda and handled
Objects:: An object with a before_foo method on it to call.
Procs:: A proc to call with the object.
Strings:: Some content to evaluate.
Symbols:: A method to call.
Filters support:
def make_lambda(filter) case filter when Symbol lambda { |target, _, &blk| target.send filter, &blk } when String l = eval "lambda { |value| #{filter} }" lambda { |target, value| target.instance_exec(value, &l) } when Conditionals::Value then filter when ::Proc if filter.arity > 1 return lambda { |target, _, &block| raise ArgumentError unless block target.instance_exec(target, block, &filter) } end if filter.arity <= 0 lambda { |target, _| target.instance_exec(&filter) } else lambda { |target, _| target.instance_exec(target, &filter) } end else scopes = Array(chain_config[:scope]) method_to_call = scopes.map{ |s| public_send(s) }.join("_") lambda { |target, _, &blk| filter.public_send method_to_call, target, &blk } end end