Class: Envconfig::Root
- Inherits:
-
Object
- Object
- Envconfig::Root
- Defined in:
- lib/envconfig.rb
Instance Method Summary collapse
- #database ⇒ Object
- #database? ⇒ Boolean
-
#initialize(env) ⇒ Root
constructor
A new instance of Root.
- #memcached ⇒ Object
- #memcached? ⇒ Boolean
- #mongodb ⇒ Object
- #mongodb? ⇒ Boolean
- #redis ⇒ Object
- #redis? ⇒ Boolean
- #smtp ⇒ Object
- #smtp? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(env) ⇒ Root
Returns a new instance of Root.
21 22 23 24 |
# File 'lib/envconfig.rb', line 21 def initialize(env) @env = env @_services = {} end |
Instance Method Details
#database ⇒ Object
38 39 40 |
# File 'lib/envconfig.rb', line 38 def database service_for(:database, Database) end |
#database? ⇒ Boolean
42 43 44 |
# File 'lib/envconfig.rb', line 42 def database? predicate_for(:database) end |
#memcached ⇒ Object
46 47 48 |
# File 'lib/envconfig.rb', line 46 def memcached service_for(:memcached, Memcached) end |
#memcached? ⇒ Boolean
50 51 52 |
# File 'lib/envconfig.rb', line 50 def memcached? predicate_for(:memcached) end |
#mongodb ⇒ Object
54 55 56 |
# File 'lib/envconfig.rb', line 54 def mongodb service_for(:mongodb, Mongodb) end |
#mongodb? ⇒ Boolean
58 59 60 |
# File 'lib/envconfig.rb', line 58 def mongodb? predicate_for(:mongodb) end |
#redis ⇒ Object
62 63 64 |
# File 'lib/envconfig.rb', line 62 def redis service_for(:redis, Redis) end |
#redis? ⇒ Boolean
66 67 68 |
# File 'lib/envconfig.rb', line 66 def redis? predicate_for(:redis) end |
#smtp ⇒ Object
70 71 72 |
# File 'lib/envconfig.rb', line 70 def smtp service_for(:smtp, Smtp) end |
#smtp? ⇒ Boolean
74 75 76 |
# File 'lib/envconfig.rb', line 74 def smtp? predicate_for(:smtp) end |
#to_h ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/envconfig.rb', line 26 def to_h [ :database, :memcached, :mongodb, :redis, :smtp, ].inject({}) do |hash, service| hash.merge!(service => public_send(service).to_h) end end |