Class: Builderator::Config::Attributes::Namespace

Inherits:
Builderator::Config::Attributes show all
Defined in:
lib/builderator/config/attributes.rb

Overview

Define a namespace for attributes

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from Builderator::Config::Attributes

#attributes, #extends, #nodes, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Builderator::Config::Attributes

#==, attribute, #clean, collection, #compile, #dirty, #dirty!, #merge, namespace, #reset!, #root, #root?, #seal, #to_json, #unseal

Constructor Details

#initialize(attributes, options = {}, &block) ⇒ Namespace

Returns a new instance of Namespace.



297
298
299
300
301
302
# File 'lib/builderator/config/attributes.rb', line 297

def initialize(attributes, options = {}, &block)
  super(attributes, options, &block)

  @name = options.fetch(:name, self.class.name)
  @collection = options[:collection]
end

Class Attribute Details

.nameObject

Returns the value of attribute name.



276
277
278
# File 'lib/builderator/config/attributes.rb', line 276

def name
  @name
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



295
296
297
# File 'lib/builderator/config/attributes.rb', line 295

def collection
  @collection
end

#nameObject (readonly)

Returns the value of attribute name.



294
295
296
# File 'lib/builderator/config/attributes.rb', line 294

def name
  @name
end

Class Method Details

.create(namespace_name, &definition) ⇒ Object

Construct a new child-class to define the interface. The constructor accepts an attributes argument, which should be a sub-node of the root attribute-set.



283
284
285
286
287
288
289
290
291
# File 'lib/builderator/config/attributes.rb', line 283

def create(namespace_name, &definition)
  space = Class.new(self)
  space.name = namespace_name

  ## Define DSL interface
  space.instance_eval(&definition) if definition

  space
end