Class: FlexibleEnum::Configuration

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
# File 'lib/flexible_enum/configuration.rb', line 7

def initialize
  @config = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(element_name, value, options = {}) ⇒ Object



15
16
17
18
# File 'lib/flexible_enum/configuration.rb', line 15

def method_missing(element_name, value, options = {})
  @config[element_name] = options
  @config[element_name][:value] = value
end

Class Method Details

.load(&block) ⇒ Object



3
4
5
# File 'lib/flexible_enum/configuration.rb', line 3

def self.load(&block)
  new.tap {|i| i.instance_eval(&block) }
end

Instance Method Details

#elementsObject



11
12
13
# File 'lib/flexible_enum/configuration.rb', line 11

def elements
  @config.dup
end