Class: Object

Inherits:
BasicObject
Defined in:
lib/lucid/core_ext/instance_exec.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#lucid_instance_exec(check_arity, pseudo_method, *args, &block) ⇒ Object

TODO: Move most of this stuff out to an InstanceExecutor class.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lucid/core_ext/instance_exec.rb', line 12

def lucid_instance_exec(check_arity, pseudo_method, *args, &block)
  lucid_run_with_backtrace_filtering(pseudo_method) do
    if check_arity && !lucid_compatible_arity?(args, block)
      instance_exec do
        ari = block.arity
        ari = ari < 0 ? (ari.abs-1).to_s+"+" : ari
        s1 = ari == 1 ? "" : "s"
        s2 = args.length == 1 ? "" : "s"
        raise Lucid::ArityMismatchError.new(
          "Your block takes #{ari} argument#{s1}, but the regexp matched #{args.length} argument#{s2}."
        )
      end
    else
      instance_exec(*args, &block)
    end
  end
end