module ActsAsLayoutable class TemplateBuilder < ActsAsLayoutable::Builder def method_missing(meth, *args, &block) key = meth.to_s path = args.shift || key.dup template = ActsAsLayoutable::Template.new(path, key) Template.all << template self.collection << template template end end class Template attr_accessor :path, :key def initialize(path, key) @path = path @key = key end class << self attr_accessor :all def all @all ||= [] end end end end