Class: Milieu::Schema
- Inherits:
-
Object
- Object
- Milieu::Schema
- Defined in:
- lib/milieu/schema.rb
Instance Attribute Summary collapse
-
#env_overrides ⇒ Object
Returns the value of attribute env_overrides.
-
#env_variables ⇒ Object
Returns the value of attribute env_variables.
Class Method Summary collapse
Instance Method Summary collapse
- #add(key, value, overrides = {}) ⇒ Object
-
#initialize ⇒ Schema
constructor
A new instance of Schema.
- #remove(key) ⇒ Object
Constructor Details
#initialize ⇒ Schema
Returns a new instance of Schema.
14 15 16 17 |
# File 'lib/milieu/schema.rb', line 14 def initialize @env_variables = {} @env_overrides = {development: {}, test: {}, production: {}} end |
Instance Attribute Details
#env_overrides ⇒ Object
Returns the value of attribute env_overrides.
6 7 8 |
# File 'lib/milieu/schema.rb', line 6 def env_overrides @env_overrides end |
#env_variables ⇒ Object
Returns the value of attribute env_variables.
5 6 7 |
# File 'lib/milieu/schema.rb', line 5 def env_variables @env_variables end |
Class Method Details
.create(&block) ⇒ Object
8 9 10 11 12 |
# File 'lib/milieu/schema.rb', line 8 def self.create(&block) new.tap do |schema| schema.instance_eval(&block) end end |
Instance Method Details
#add(key, value, overrides = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/milieu/schema.rb', line 19 def add(key, value, overrides = {}) env_key = normalize_key(key) @env_variables[env_key] = value if overrides[:development] @env_overrides[:development][env_key] = overrides[:development] end if overrides[:test] @env_overrides[:test][env_key] = overrides[:test] end if overrides[:production] @env_overrides[:production][env_key] = overrides[:production] end self end |
#remove(key) ⇒ Object
34 35 36 37 |
# File 'lib/milieu/schema.rb', line 34 def remove(key) @env_variables.delete(normalize_key(key)) self end |