Sha256: 0f1aa52b7cca56f41dbe3718805f8797a900b08942904d7218d6d01039acd5f0
Contents?: true
Size: 715 Bytes
Versions: 4
Compression:
Stored size: 715 Bytes
Contents
module Guts # Option model class Option < ActiveRecord::Base include MultisiteScopeConcern # Regex for replacing key values with KEY_REGEX = /[^a-zA-Z0-9_ ]/i validates :key, presence: true, length: { minimum: 3 } belongs_to :site has_many :tracks, as: :object # Setter override for setting key # @param [String] key the option key # @return [String] cleaned/formatted key def key=(key) self[:key] = key.gsub(KEY_REGEX, '').gsub(/\s+/, '_').downcase.chomp end # Simple helper lookup for keys # @param [Symbol] key the option key to look up # @return [Object] the option record def self.for_key(key) find_by key: key end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
guts-2.1.0 | app/models/guts/option.rb |
guts-2.0.2 | app/models/guts/option.rb |
guts-2.0.1 | app/models/guts/option.rb |
guts-2.0.0 | app/models/guts/option.rb |