Sha256: 4ce7ae1100cd49b29947adfa4d97d9e4b68a663f326d5ba3657f8d2535f67b10
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
# rubocop:disable all # module Familia # InstanceMethods - Module containing instance-level methods for Familia # # This module is included in classes that include Familia, providing # instance-level functionality for Redis operations and object management. # class Horreum # Utils - Module containing utility methods for Familia::Horreum (InstanceMethods) # module Utils def redisuri(suffix = nil) u = Familia.redisuri(self.class.uri) # returns URI::Redis u.db ||= self.class.db.to_s # TODO: revisit logic (should the horrerum instance know its uri?) u.key = rediskey(suffix) u end # +suffix+ is the value to be used at the end of the redis key # (e.g. `customer:customer_id:scores` would have `scores` as the suffix # and `customer_id` would have been the identifier in that case). # # identifier is the value that distinguishes this object from others. # Whether this is a Horreum or RedisType object, the value is taken # from the `identifier` method). # def rediskey(suffix = nil, ignored = nil) raise Familia::NoIdentifier, "No identifier for #{self.class}" if identifier.to_s.empty? suffix ||= self.suffix # use the instance method to get the default suffix self.class.rediskey identifier, suffix end def join(*args) Familia.join(args.map { |field| send(field) }) end end include Utils # these become Horreum instance methods end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
familia-1.0.0.pre.rc5 | lib/familia/horreum/utils.rb |
familia-1.0.0.pre.rc4 | lib/familia/horreum/utils.rb |