class Airspace::Key
This class understands how to build keys and subkeys for storing data inside Redis.
Constants
- SEPARATOR_CHAR
Attributes
id[R]
prefix[R]
Public Class Methods
new(id, prefix: '')
click to toggle source
# File lib/airspace/key.rb, line 19 def initialize(id, prefix: '') @id = id.to_s @prefix = prefix.to_s end
Public Instance Methods
chunk(index)
click to toggle source
# File lib/airspace/key.rb, line 31 def chunk(index) [root, index].join(SEPARATOR_CHAR) end
root()
click to toggle source
# File lib/airspace/key.rb, line 24 def root return id if prefix.empty? [prefix, id].join(SEPARATOR_CHAR) end
Also aliased as: to_s