class ConfConf::Project::Environment

Public Class Methods

load(project, name) click to toggle source
# File lib/conf_conf/project/environment.rb, line 5
def load(project, name)
  ConfConf::Project::Environment::Storage.load_project_environment(project, name)
end
new(*args) click to toggle source
Calls superclass method
# File lib/conf_conf/project/environment.rb, line 10
def initialize(*args)
  super
  self.variables  ||= {}
  self.schema     ||= {}
end

Public Instance Methods

get(variable_name) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

normalized_variable_name(variable_name) click to toggle source
# File lib/conf_conf/project/environment.rb, line 48
def normalized_variable_name(variable_name)
  variable_name.strip.upcase
end