Class: DelayedSunspot::Sunspot::Configuration

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Configuration

Returns a new instance of Configuration.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/delayed_sunspot/sunspot/configuration.rb', line 4

def initialize(config)
  @config = config
  singleton = (class <<self; self; end)
  @properties = @config.instance_variable_get("@properties") || {}
  @properties.keys.each do |key|
    singleton.module_eval do
      define_method key do
        if @properties[key].is_a?(LightConfig::Configuration)
          self.class.new(@properties[key])
        else
          @properties[key]
        end
      end
      define_method "#{key}=" do |value|
        @properties[key] = value
      end
    end
  end
end