Module: Familia::Horreum::Utils
- Included in:
- Familia::Horreum
- Defined in:
- lib/familia/horreum/utils.rb
Overview
Utils - Module containing utility methods for Familia::Horreum (InstanceMethods)
Instance Method Summary collapse
- #join(*args) ⇒ Object
-
#rediskey(suffix = self.suffix, ignored = nil) ⇒ Object
suffixis 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). - #redisuri(suffix = nil) ⇒ Object
Instance Method Details
#join(*args) ⇒ Object
36 37 38 |
# File 'lib/familia/horreum/utils.rb', line 36 def join(*args) Familia.join(args.map { |field| send(field) }) end |
#rediskey(suffix = self.suffix, ignored = nil) ⇒ Object
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).
30 31 32 33 34 |
# File 'lib/familia/horreum/utils.rb', line 30 def rediskey(suffix = self.suffix, ignored = nil) Familia.ld "[#rediskey] #{identifier} for #{self.class}" raise Familia::NoIdentifier, "No identifier for #{self.class}" if identifier.to_s.empty? self.class.rediskey identifier, suffix end |
#redisuri(suffix = nil) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/familia/horreum/utils.rb', line 15 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 |