Class: ConfConf::Project::Environment
- Inherits:
-
Struct
- Object
- Struct
- ConfConf::Project::Environment
- Defined in:
- lib/conf_conf/project/environment.rb,
lib/conf_conf/project/environment/storage.rb
Defined Under Namespace
Classes: NotAuthorizedError, Storage
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#project ⇒ Object
Returns the value of attribute project.
-
#schema ⇒ Object
Returns the value of attribute schema.
-
#variables ⇒ Object
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
- #get(variable_name) ⇒ Object
-
#initialize(*args) ⇒ Environment
constructor
A new instance of Environment.
- #remove(variable_name) ⇒ Object
- #save ⇒ Object
- #set(variable_name, variable_value) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Environment
10 11 12 13 14 |
# File 'lib/conf_conf/project/environment.rb', line 10 def initialize(*args) super self.variables ||= {} self.schema ||= {} end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/conf_conf/project/environment.rb', line 3 def name @name end |
#project ⇒ Object
Returns the value of attribute project
3 4 5 |
# File 'lib/conf_conf/project/environment.rb', line 3 def project @project end |
#schema ⇒ Object
Returns the value of attribute schema
3 4 5 |
# File 'lib/conf_conf/project/environment.rb', line 3 def schema @schema end |
#variables ⇒ Object
Returns the value of attribute variables
3 4 5 |
# File 'lib/conf_conf/project/environment.rb', line 3 def variables @variables end |
Class Method Details
.load(project, name) ⇒ Object
5 6 7 |
# File 'lib/conf_conf/project/environment.rb', line 5 def load(project, name) ConfConf::Project::Environment::Storage.load_project_environment(project, name) end |
Instance Method Details
#get(variable_name) ⇒ Object
16 17 18 19 |
# File 'lib/conf_conf/project/environment.rb', line 16 def get(variable_name) variable_name = normalized_variable_name(variable_name) variables[variable_name] end |
#remove(variable_name) ⇒ Object
37 38 39 40 41 |
# File 'lib/conf_conf/project/environment.rb', line 37 def remove(variable_name) variable_name = normalized_variable_name(variable_name) schema.delete variable_name variables.delete variable_name end |
#save ⇒ Object
43 44 45 |
# File 'lib/conf_conf/project/environment.rb', line 43 def save ConfConf::Project::Environment::Storage.save_project_environment(project, self) end |
#set(variable_name, variable_value) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/conf_conf/project/environment.rb', line 21 def set(variable_name, variable_value) variable_name = normalized_variable_name(variable_name) if variables[variable_name] != variable_value schema.delete variable_name end if schema[variable_name] && schema[variable_name]['access'] schema[variable_name]['access'] = (project.developers.keys + schema[variable_name]['access']).to_a else schema[variable_name] = { 'access' => project.developers.keys.to_a } end variables[variable_name] = variable_value end |