Class: ENVied
- Inherits:
-
Object
- Object
- ENVied
- Defined in:
- lib/envied.rb
Defined Under Namespace
Modules: Configurable
Constant Summary collapse
- VERSION =
"0.2.0"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .[](key) ⇒ Object
- .configure(&block) ⇒ Object
- .instance ⇒ Object (also: require!)
- .method_missing(method, *args, &block) ⇒ Object
- .respond_to_missing?(method, include_private = false) ⇒ Boolean
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
90 91 92 |
# File 'lib/envied.rb', line 90 def configuration @configuration end |
Class Method Details
.[](key) ⇒ Object
109 110 111 112 |
# File 'lib/envied.rb', line 109 def self.[](key) instance.attributes[key] #instance[key] # will raise and complain that <class <>> doesn't response; better? end |
.configure(&block) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/envied.rb', line 93 def self.configure(&block) @configuration = Class.new { include Configurable }.tap do |k| k.instance_eval(&block) end # or define this thing as ENVied::Configuration? prolly not threadsafe ensure @instance = nil end |
.instance ⇒ Object Also known as: require!
102 103 104 |
# File 'lib/envied.rb', line 102 def self.instance @instance ||= @configuration.parse_env(ENV.to_hash) end |
.method_missing(method, *args, &block) ⇒ Object
114 115 116 |
# File 'lib/envied.rb', line 114 def self.method_missing(method, *args, &block) respond_to_missing?(method) ? instance.public_send(method, *args, &block) : super end |
.respond_to_missing?(method, include_private = false) ⇒ Boolean
118 119 120 |
# File 'lib/envied.rb', line 118 def self.respond_to_missing?(method, include_private = false) instance.attributes.key?(method) || super end |