class Builderator::Config::Attributes::Collection
Enumerable wrapper for collections
Attributes
name[RW]
namespace_class[RW]
current[R]
Allow a single instance to be selected
Public Class Methods
create(collection_name, &definition)
click to toggle source
# File lib/builderator/config/attributes.rb, line 316 def create(collection_name, &definition) collection = Class.new(self) collection.name = collection_name collection.namespace_class = Namespace.create(collection_name, &definition) collection end
Public Instance Methods
each(&block)
click to toggle source
Enumerable methods return namespace instances
# File lib/builderator/config/attributes.rb, line 332 def each(&block) attributes.each_key do |instance_name| block.call(instance_name, fetch(instance_name)) end end
fetch(instance_name, **options, &block)
click to toggle source
Get namespace instances
# File lib/builderator/config/attributes.rb, line 343 def fetch(instance_name, **options, &block) nodes[instance_name] ||= self.class.namespace_class.new( attributes[instance_name], :collection => self, :name => instance_name, :parent => self, :extends => options[:extends], &block) end
Also aliased as: []
name()
click to toggle source
# File lib/builderator/config/attributes.rb, line 338 def name self.class.name end
use(instance_name)
click to toggle source
# File lib/builderator/config/attributes.rb, line 327 def use(instance_name) @current = fetch(instance_name) end