Class: Declarative::Definitions::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/declarative/definitions.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}, &block) ⇒ Definition

Returns a new instance of Definition.



4
5
6
7
# File 'lib/declarative/definitions.rb', line 4

def initialize(name, options={}, &block)
  @options = options.dup
  @options[:name] = name.to_s
end

Instance Method Details

#[](name) ⇒ Object



9
10
11
# File 'lib/declarative/definitions.rb', line 9

def [](name)
  @options[name]
end

#merge(hash) ⇒ Object

TODO: should be called #copy.



18
19
20
# File 'lib/declarative/definitions.rb', line 18

def merge(hash) # TODO: should be called #copy.
  DeepDup.(@options).merge(hash)
end

#merge!(hash) ⇒ Object

TODO: this should return a new Definition instance.



13
14
15
16
# File 'lib/declarative/definitions.rb', line 13

def merge!(hash) # TODO: this should return a new Definition instance.
  @options.merge!(hash)
  self
end