Module: Familia::Base

Included in:
Horreum, RedisType
Defined in:
lib/familia/base.rb

Overview

A common module for Familia::RedisType and Familia::Horreum to include.

This allows us to use a single comparison to check if a class is a Familia class. e.g.

klass.include?(Familia::Base) # => true
klass.ancestors.member?(Familia::Base) # => true

See Also:

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.dump_methodObject

Returns the value of attribute dump_method.



23
24
25
# File 'lib/familia/base.rb', line 23

def dump_method
  @dump_method
end

.featuresObject (readonly)

Returns the value of attribute features.



22
23
24
# File 'lib/familia/base.rb', line 22

def features
  @features
end

.load_methodObject

Returns the value of attribute load_method.



23
24
25
# File 'lib/familia/base.rb', line 23

def load_method
  @load_method
end

Class Method Details

.add_feature(klass, methname) ⇒ Object



25
26
27
28
29
30
# File 'lib/familia/base.rb', line 25

def add_feature(klass, methname)
  @features ||= {}
  Familia.ld "[#{self}] Adding feature #{klass} as #{methname.inspect}"

  features[methname] = klass
end

Instance Method Details

#generate_idObject



51
52
53
54
# File 'lib/familia/base.rb', line 51

def generate_id
  @key ||= Familia.generate_id
  @key
end

#update_expiration(ttl: nil) ⇒ nil

Note:

This is a no-op implementation. Classes that need expiration functionality should include the :expiration feature.

Base implementation of update_expiration that maintains API compatibility with the :expiration feature’s implementation.

This is a no-op implementation that gets overridden by features like :expiration. It accepts an optional ttl parameter to maintain interface compatibility with the overriding implementations.

Parameters:

  • ttl (Integer, nil) (defaults to: nil)

    Time To Live in seconds (ignored in base implementation)

Returns:

  • (nil)

    Always returns nil



46
47
48
49
# File 'lib/familia/base.rb', line 46

def update_expiration(ttl: nil)
  Familia.ld "[update_expiration] Feature not enabled for #{self.class}. Key: #{rediskey} (caller: #{caller(1..1)})"
  nil
end

#uuidObject



56
57
58
59
# File 'lib/familia/base.rb', line 56

def uuid
  @uuid ||= SecureRandom.uuid
  @uuid
end