Module: Iolite::Placeholders

Defined in:
lib/iolite/placeholders.rb

Class Method Summary collapse

Class Method Details

.argsObject



4
5
6
7
8
# File 'lib/iolite/placeholders.rb', line 4

def args
  Lazy.new { |*args|
    args
  }
end

.argument(index) ⇒ Object



11
12
13
14
15
# File 'lib/iolite/placeholders.rb', line 11

def argument index
  Lazy.new { |*args|
    args[index-1]
  }
end

.prepare(n) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/iolite/placeholders.rb', line 18

def prepare n
  1.upto(n).each { |i|
    const_set("ARG#{i}", argument(i))
    define_method("arg#{i}") do
      Placeholders.const_get("ARG#{i}")
    end
    module_function "arg#{i}"
    alias_method "_#{i}", "arg#{i}"
  }
end