1 class Radiant::AdminUI::RegionPartials
2 def initialize(template)
3 @partials = Hash.new {|h,k| h[k] = "<strong>`#{k}' default partial not found!</strong>" }
4 @template = template
5 end
6
7 def [](key)
8 @partials[key.to_s]
9 end
10
11 def method_missing(method, *args, &block)
12 if block_given?
13 # Ruby 1.9.2 yields self in instance_eval... see https://gist.github.com/479572
14 # lambdas are as strict as methods in 1.9.x, making sure that the args match, Procs are not.
15 if RUBY_VERSION =~ /^1\.9/ and block.lambda? and block.arity != 1
16 raise "You can only pass a proc ('Proc.new') or a lambda that takes exactly one arg (for self) to Radiant::AdminUI::RegionPartials' method_missing."
17 end
18 @partials[method.to_s] = @template.capture(&block)
19 else
20 @partials[method.to_s]
21 end
22 end
23 en