Class: SimpleMetrics::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}, &block) ⇒ Configuration

Returns a new instance of Configuration.



8
9
10
# File 'lib/simple_metrics/configuration.rb', line 8

def initialize(hash = {}, &block)
  @config = load_defaults.merge(hash.symbolize_keys)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

Instance Method Details

#bucketsObject



25
26
27
28
29
30
# File 'lib/simple_metrics/configuration.rb', line 25

def buckets
  @buckets ||= begin
    tmp = config.fetch(:buckets)
    tmp.map { |b| b.symbolize_keys }
  end
end

#buckets=(buckets) ⇒ Object



32
33
34
# File 'lib/simple_metrics/configuration.rb', line 32

def buckets=(buckets)
  @buckets = buckets
end

#configure(hash = {}) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



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

def configure(hash = {}, &block)
  yield self if block_given?
  self
end

#dbObject



17
18
19
# File 'lib/simple_metrics/configuration.rb', line 17

def db
  @db ||= config.fetch(:db).symbolize_keys
end

#db=(db) ⇒ Object



21
22
23
# File 'lib/simple_metrics/configuration.rb', line 21

def db=(db)
  @db = db
end

#serverObject



36
37
38
# File 'lib/simple_metrics/configuration.rb', line 36

def server
  @server ||= config.fetch(:server).symbolize_keys
end

#server=(server) ⇒ Object



40
41
42
# File 'lib/simple_metrics/configuration.rb', line 40

def server=(server)
  @server = server
end

#webObject



44
45
46
# File 'lib/simple_metrics/configuration.rb', line 44

def web
  @web ||= config.fetch(:web).symbolize_keys
end

#web=(web) ⇒ Object



48
49
50
# File 'lib/simple_metrics/configuration.rb', line 48

def web=(web)
  @web = web
end