Sha256: a5d8973729cd61a210b276c512497969ba3a31d6de413297169edbc1f476d7de
Contents?: true
Size: 960 Bytes
Versions: 1
Compression:
Stored size: 960 Bytes
Contents
require "kue/version" module Kue class KueNilKeyError < StandardError; end module Store def self.included(base) base.send :extend, ClassMethods base.send :set_table_name, :kue_settings base.send :set_primary_key, :key end module ClassMethods def keys KueStore.all.map(&:key).map(&:to_sym) end def [](key) entry = KueStore.find_by_key(key) entry ? YAML.load(entry.value) : nil end def []=(key, value) raise KueNilKeyError if key.nil? setting = KueStore.find_or_create_by_key(key) setting.value = value.to_yaml setting.save! end def delete!(key) KueStore.delete_all(:key => key) end def exists?(key) self[key].present? end def clear! KueStore.destroy_all end end end end class KueStore < ActiveRecord::Base include Kue::Store end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kue-0.0.8 | lib/kue.rb |