Class: Guts::Option
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Guts::Option
- Includes:
- MultisiteScopeConcern
- Defined in:
- app/models/guts/option.rb
Overview
Option model
Constant Summary collapse
- KEY_REGEX =
Regex for replacing key values with
/[^a-zA-Z0-9_ ]/i
Class Method Summary collapse
-
.for_key(key) ⇒ Object
Simple helper lookup for keys.
Instance Method Summary collapse
-
#key=(key) ⇒ String
Setter override for setting key.
Class Method Details
.for_key(key) ⇒ Object
Simple helper lookup for keys
23 24 25 |
# File 'app/models/guts/option.rb', line 23 def self.for_key(key) find_by key: key end |
Instance Method Details
#key=(key) ⇒ String
Setter override for setting key
16 17 18 |
# File 'app/models/guts/option.rb', line 16 def key=(key) self[:key] = key.gsub(KEY_REGEX, '').gsub(/\s+/, '_').downcase.chomp end |