Class: GlobalOptions::GlobalOption
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- GlobalOptions::GlobalOption
- Defined in:
- app/models/global_options/global_option.rb
Defined Under Namespace
Classes: NotFound
Class Method Summary collapse
Class Method Details
.by_name(name) ⇒ Object
7 8 9 10 11 |
# File 'app/models/global_options/global_option.rb', line 7 def self.by_name(name) option = where(name: name).first raise NotFound, "Option not found by that name: '#{name}'." unless option return option end |
.get(name) ⇒ Object
19 20 21 |
# File 'app/models/global_options/global_option.rb', line 19 def self.get(name) by_name(name).value end |
.set(name, value) ⇒ Object
13 14 15 16 17 |
# File 'app/models/global_options/global_option.rb', line 13 def self.set(name, value) option = find_or_initialize_by(name: name) option.value = value option.save! end |