Class: Chamber::Filters::EnvironmentFilter
- Inherits:
-
Object
- Object
- Chamber::Filters::EnvironmentFilter
- Includes:
- Environmentable
- Defined in:
- lib/chamber/filters/environment_filter.rb
Class Method Summary collapse
-
.execute(options = {}) ⇒ Object
Internal: Allows the existing environment to be injected into the passed in hash.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ EnvironmentFilter
constructor
A new instance of EnvironmentFilter.
Methods included from Environmentable
Constructor Details
#initialize(options = {}) ⇒ EnvironmentFilter
Returns a new instance of EnvironmentFilter.
8 9 10 |
# File 'lib/chamber/filters/environment_filter.rb', line 8 def initialize( = {}) self.data = .fetch(:data) end |
Class Method Details
.execute(options = {}) ⇒ Object
Internal: Allows the existing environment to be injected into the passed in hash. The hash that is passed in is not modified, instead a new hash is returned.
Examples:
###
# Injects the current environment variables
#
ENV['LEVEL_ONE_1_LEVEL_TWO_1'] = 'env value 1'
ENV['LEVEL_ONE_1_LEVEL_TWO_2_LEVEL_THREE_1'] = 'env value 2'
EnvironmentFilter.execute(
level_one_1: {
level_two_1: 'value 1',
level_two_2: {
level_three_1: 'value 2' } } )
# => {
'level_one_1' => {
'level_two_1' => 'env value 1',
'level_two_2' => {
'level_three_1' => 'env value 2',
}
###
# Can inject environment variables if said variables are prefixed
#
ENV['PREFIX_LEVEL_TWO_1'] = 'env value 1'
ENV['PREFIX_LEVEL_TWO_2'] = 'env value 2'
EnvironmentFilter.execute({
level_two_1: 'value 1',
level_two_2: 'value 2'
},
['prefix'])
# => {
'level_two_1' => 'env value 1',
'level_two_2' => 'env value 2',
}
56 57 58 |
# File 'lib/chamber/filters/environment_filter.rb', line 56 def self.execute( = {}) self.new().send(:execute) end |