Class: Remotenv::Adapters::Base
- Inherits:
-
Object
- Object
- Remotenv::Adapters::Base
- Defined in:
- lib/remotenv/adapters/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #after_load ⇒ Object
- #apply_environment ⇒ Object
- #before_load ⇒ Object
- #get(key) ⇒ Object
-
#initialize(uri, options = {}) ⇒ Base
constructor
A new instance of Base.
- #load ⇒ Object
- #load! ⇒ Object
- #set_refresh_timestamp ⇒ Object
Constructor Details
#initialize(uri, options = {}) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 |
# File 'lib/remotenv/adapters/base.rb', line 10 def initialize(uri, = {}) @uri = uri = @data = {} @content = nil end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/remotenv/adapters/base.rb', line 7 def data @data end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/remotenv/adapters/base.rb', line 8 def end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/remotenv/adapters/base.rb', line 6 def uri @uri end |
Instance Method Details
#after_load ⇒ Object
33 34 |
# File 'lib/remotenv/adapters/base.rb', line 33 def after_load end |
#apply_environment ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/remotenv/adapters/base.rb', line 40 def apply_environment Remotenv.logger.debug("Applying environment variables") @data = Dotenv::Parser.call(@content) Remotenv.logger.debug("ENV: #{@data.keys.join(', ')}") @data.each do |key, value| ENV[key] ||= value end end |
#before_load ⇒ Object
26 27 |
# File 'lib/remotenv/adapters/base.rb', line 26 def before_load end |
#get(key) ⇒ Object
49 50 51 |
# File 'lib/remotenv/adapters/base.rb', line 49 def get(key) @data[key] end |
#load ⇒ Object
29 30 31 |
# File 'lib/remotenv/adapters/base.rb', line 29 def load raise "Remotenv::Adapter::Base should not be used directly" end |
#load! ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/remotenv/adapters/base.rb', line 17 def load! Remotenv.logger.debug("Adapter: #{self.class.name}") before_load load after_load apply_environment end |
#set_refresh_timestamp ⇒ Object
36 37 38 |
# File 'lib/remotenv/adapters/base.rb', line 36 def ENV['REMOTENV_REFRESHED_AT'] = Time.now.to_s end |