summaryrefslogtreecommitdiff
path: root/app/models/gs_parameter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/gs_parameter.rb')
-rw-r--r--app/models/gs_parameter.rb25
1 files changed, 16 insertions, 9 deletions
diff --git a/app/models/gs_parameter.rb b/app/models/gs_parameter.rb
index 8e30583..9d9e996 100644
--- a/app/models/gs_parameter.rb
+++ b/app/models/gs_parameter.rb
@@ -12,16 +12,23 @@ class GsParameter < ActiveRecord::Base
:presence => true,
:inclusion => { :in => ['String', 'Integer', 'Boolean', 'YAML'] }
- def generate_constant
- Kernel.const_set(self.name, self.value.to_i) if self.class_type == 'Integer'
- Kernel.const_set(self.name, self.value.to_s) if self.class_type == 'String'
-
- if self.class_type == 'Boolean'
- Kernel.const_set(self.name, true) if self.value == 'true'
- Kernel.const_set(self.name, false) if self.value == 'false'
+ def self.get(wanted_variable)
+ if GsParameter.table_exists?
+ item = GsParameter.where(:name => wanted_variable).first
+ if item.nil?
+ return nil
+ else
+ return item.value.to_i if item.class_type == 'Integer'
+ return item.value.to_s if item.class_type == 'String'
+ if item.class_type == 'Boolean'
+ return true if item.value == 'true'
+ return false if item.value == 'false'
+ end
+ return YAML.load(item.value) if item.class_type == 'YAML'
+ end
+ else
+ nil
end
-
- Kernel.const_set(self.name, YAML.load(self.value)) if self.class_type == 'YAML'
end
def to_s