Class: Codeclimate::Collectors::Configuration

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

Overview

The configuration for a collector client. Used like a Hash. Treats all keys as symbols.

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Configuration

Returns a new instance of Configuration.



6
7
8
# File 'lib/codeclimate/collectors/configuration.rb', line 6

def initialize(attrs = {})
  @storage = attrs.deep_symbolize_keys
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/codeclimate/collectors/configuration.rb', line 10

def [](key)
  storage[key.to_sym]
end

#[]=(key, val) ⇒ Object



14
15
16
# File 'lib/codeclimate/collectors/configuration.rb', line 14

def []=(key, val)
  storage[key.to_sym] = val
end

#fetch(*args) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/codeclimate/collectors/configuration.rb', line 18

def fetch(*args)
  case args.count
  when 1
    storage.fetch(args[0].to_sym)
  when 2
    storage.fetch(args[0].to_sym, args[1])
  else
    raise ArgumentError, "expected 1 or 2 arguments"
  end
end