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_expirationnil

Note:

This method is a no-op. It’s like shouting into the void, but less echo-y.

Yo, this class is like that one friend who never checks expiration dates. It’s living life on the edge, data-style!

Examples:

Trying to teach an old dog new tricks

immortal_data.update_expiration(86400) # Nice try, but this data is here to stay!

Parameters:

  • ttl (Integer, nil)

    Time To Live? More like Time To Laugh! This param is here for compatibility, but it’s as useful as a chocolate teapot.

Returns:

  • (nil)

    Always returns nil. It’s consistent in its laziness!



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

def update_expiration(*)
  Familia.info "[update_expiration] Skipped for #{rediskey}. #{self.class} data is immortal!"
  nil
end

#uuidObject



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

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