Module: Variant
- Defined in:
- lib/variant/version.rb,
lib/variant.rb,
lib/variant/environment.rb
Overview
Copyright, 2016, by Samuel G. D. Williams. <www.codeotaku.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defined Under Namespace
Classes: Environment
Constant Summary collapse
- KEY =
'VARIANT'
- SUFFIX =
'_VARIANT'
- VERSION =
"0.1.1"
- DEVELOPMENT =
:development
- PRODUCTION =
:production
- TESTING =
:testing
- STAGING =
:staging
Class Method Summary collapse
- .default ⇒ Object
- .default=(value) ⇒ Object
- .for(*arguments) ⇒ Object
-
.force!(value, environment = ENV, **overrides) ⇒ Object
Force the process-level variant to be the specified value.
Class Method Details
.default ⇒ Object
53 54 55 |
# File 'lib/variant.rb', line 53 def self.default Environment.instance.default_variant end |
.default=(value) ⇒ Object
57 58 59 |
# File 'lib/variant.rb', line 57 def self.default= value Environment.instance.default_variant= value end |
.for(*arguments) ⇒ Object
61 62 63 |
# File 'lib/variant.rb', line 61 def self.for(*arguments) Environment.instance.variant_for(*arguments) end |
.force!(value, environment = ENV, **overrides) ⇒ Object
Force the process-level variant to be the specified value.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/variant.rb', line 37 def self.force!(value, environment = ENV, **overrides) # Clear any specific variants: environment.delete_if{|key, value| key.end_with?(SUFFIX)} # Set the specified variant: environment[KEY] = value.to_s overrides.each do |name, value| key = name.upcase.to_s + SUFFIX environment[key] = value.to_s end return environment end |