Sha256: 75de4509eb04128f458b10c12f168be8a735c6987e29b2fcd1f5405f1b627333
Contents?: true
Size: 799 Bytes
Versions: 2
Compression:
Stored size: 799 Bytes
Contents
# These are just utlity functions used by Ampere internally to generate Redis # keys for various Ampere functions, for DRY excellence. module Ampere #:nodoc: module Keys #:nodoc: # These methods get mixed in to class and instance def self.included(base) # base.extend(ClassMethods) base.extend(self) end def key_for_find(parent_model, id) unless id =~ /\./ id = "#{parent_model.to_s.downcase}.#{id}" end id end def key_for_has_many(parent_model, id, field) [parent_model, id, 'has_many', field].flatten.join('.') end def key_for_index(field) ['ampere', 'index', model_name.downcase, field].flatten.join('.') end private def model_name self.class.to_s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ampere-1.2.3 | lib/ampere/keys.rb |
ampere-1.2.2 | lib/ampere/keys.rb |