Class: Reamaze::Opinionated::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/opinionated/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, preferential, options) ⇒ Configuration

Returns a new instance of Configuration.



6
7
8
9
10
# File 'lib/opinionated/configuration.rb', line 6

def initialize(klass, preferential, options)
  @klass        = klass
  @preferential = preferential
  @definitions  = {}
end

Instance Attribute Details

#definitionsObject

Returns the value of attribute definitions.



4
5
6
# File 'lib/opinionated/configuration.rb', line 4

def definitions
  @definitions
end

Instance Method Details

#define(preferential, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/opinionated/configuration.rb', line 12

def define(preferential, options = {})
  preferential = Helpers.normalize(preferential)
  raise ArgumentError, "#{@klass} already defines preferences :#{preferential}" if @definitions.has_key?(preferential)
  @definitions[preferential] = Definition.new(preferential, options)
end