Sha256: 6679d71c646edafb876a2aaca65b9d1b9f75ddb243d77fe6c4bc867f27f273b5
Contents?: true
Size: 583 Bytes
Versions: 3
Compression:
Stored size: 583 Bytes
Contents
class Snippet include Mongoid::Document field :key field :value index({ key: 1 }) scope :by_key, ->{ ascending(:key) } # Finds the value of a snippet as a html_safe string # # Snippet.find_for_key 'address' # # => "54B Downham Road" # # @param [String] key Snippet key to lookup # @return [String] # def self.find_for_key(key) find_by(key: key).value.try(:html_safe) rescue Mongoid::Errors::DocumentNotFound end def as_json(*args) { id: id.to_s, key: key, value: value, } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
slices-2.0.2 | app/models/snippet.rb |
slices-2.0.1 | app/models/snippet.rb |
slices-2.0.0 | app/models/snippet.rb |