Class: Object

Inherits:
BasicObject
Defined in:
lib/lucid/lang_extend.rb

Instance Method Summary collapse

Instance Method Details

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



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/lucid/lang_extend.rb', line 55

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 expression matched #{args.length} argument#{s2}."
        )
      end
    else
      instance_exec(*args, &block)
    end
  end
end