Class: SimpleMetrics::Configuration
- Inherits:
-
Object
- Object
- SimpleMetrics::Configuration
- Defined in:
- lib/simple_metrics/configuration.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #buckets ⇒ Object
- #buckets=(buckets) ⇒ Object
- #configure(hash = {}) {|_self| ... } ⇒ Object
- #db ⇒ Object
- #db=(db) ⇒ Object
-
#initialize(hash = {}, &block) ⇒ Configuration
constructor
A new instance of Configuration.
- #server ⇒ Object
- #server=(server) ⇒ Object
- #web ⇒ Object
- #web=(web) ⇒ Object
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
#config ⇒ Object (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
#buckets ⇒ Object
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
12 13 14 15 |
# File 'lib/simple_metrics/configuration.rb', line 12 def configure(hash = {}, &block) yield self if block_given? self end |
#db ⇒ Object
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 |
#server ⇒ Object
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 |
#web ⇒ Object
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 |