Sha256: f043a56e81165b5d73f6958f332136af86ec116beb5a2fd5f4f6a201770fd822
Contents?: true
Size: 805 Bytes
Versions: 5
Compression:
Stored size: 805 Bytes
Contents
module Ohm # Represents a key in Redis. class Key attr :parts attr :glue attr :namespace def self.[](*parts) Key.new(parts) end def initialize(parts, glue = ":", namespace = []) @parts = parts @glue = glue @namespace = namespace end def sub_keys parts.map {|k| k.glue == ":" ? k : k.volatile } end def append(*parts) @parts += parts self end def eql?(other) to_s == other.to_s end alias == eql? def to_s (namespace + [@parts.join(glue)]).join(":") end alias inspect to_s alias to_str to_s def volatile @namespace = [:~] self end def group(glue = self.glue) Key.new([self], glue, namespace.slice!(0, namespace.size)) end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ohm-0.0.38 | lib/ohm/key.rb |
ohm-0.0.37 | lib/ohm/key.rb |
ohm-0.0.36 | lib/ohm/key.rb |
ohm-0.0.35 | lib/ohm/key.rb |
ohm-0.0.34 | lib/ohm/key.rb |