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.



300
301
302
303
304
305
# File 'lib/builderator/config/attributes.rb', line 300

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.



279
280
281
# File 'lib/builderator/config/attributes.rb', line 279

def name
  @name
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



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

def collection
  @collection
end

#nameObject (readonly)

Returns the value of attribute name.



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

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.



286
287
288
289
290
291
292
293
294
# File 'lib/builderator/config/attributes.rb', line 286

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

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

  space
end