Class: Visitors::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/visitors/config.rb

Defined Under Namespace

Classes: MissingEnvironmentError

Constant Summary collapse

DEFAULTS =
{
  :redis_namespace => "visitors_#{Visitors.env}",
  :redis_connection => {:host => '127.0.0.1'},
  :disabled => false
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loadObject



12
13
14
# File 'lib/visitors/config.rb', line 12

def self.load
  new.tap { |instance| instance.send(:define_methods_from_yaml) }
end

Instance Method Details

#allObject



20
21
22
23
# File 'lib/visitors/config.rb', line 20

def all
  return yaml[Visitors.env] if yaml[Visitors.env]
  raise MissingEnvironmentError, "#{Visitors.env.inspect} environment not configured"
end

#fieldsObject



16
17
18
# File 'lib/visitors/config.rb', line 16

def fields
  yaml['fields'] && Array(yaml['fields']).map(&:to_sym)
end

#inspectObject



25
26
27
# File 'lib/visitors/config.rb', line 25

def inspect
  all.inspect
end