Module: Familia::Horreum::Utils

Included in:
Familia::Horreum
Defined in:
lib/familia/horreum/utils.rb

Overview

Utils - Instance-level utility methods for Familia::Horreum Provides identifier handling, dbkey generation, and object inspection

Instance Method Summary collapse

Instance Method Details

#dbkey(suffix = nil, _ignored = nil) ⇒ Object

+suffix+ is the value to be used at the end of the db 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 DataType object, the value is taken from the identifier method).



24
25
26
27
28
29
# File 'lib/familia/horreum/utils.rb', line 24

def dbkey(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.dbkey identifier, suffix
end

#join(*args) ⇒ Object



31
32
33
# File 'lib/familia/horreum/utils.rb', line 31

def join(*args)
  Familia.join(args.map { |field| send(field) })
end