Sha256: 9b1e25978fc798bcca67ff58e608bd92756480a511815a83b2340750183d64fa
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
module ActsAsLayoutable class Builder class << self def define!(*args, &block) new(*args, &block).collection.uniq end end attr_accessor :item, :collection def collection @collection ||= [] end def klazz self.class.to_s.gsub("Builder", "").constantize end def initialize(*args, &block) args.each do |name| self.collection << klazz.create!(:name => name.to_s) end instance_eval(&block) if block_given? end def templates(*args, &block) TemplateBuilder.define!(*args, &block) end alias paths templates def layouts(*args, &block) LayoutBuilder.define!(*args, &block) end alias grids layouts def areas(*args, &block) AreaBuilder.define!(*args, &block) end def widgets(*args, &block) WidgetBuilder.define!(*args, &block) end alias cells widgets def method_missing(meth, *args, &block) if context result = "ActsAsLayoutable::#{context.singularize.camelize}".constantize.new result.instance_eval(&block) if block_given? return result else super(meth, *args, &block) end end private def context @context end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts-as-layoutable-0.0.1.7 | lib/acts-as-layoutable/builder.rb |