Module: Familia::Features
- Included in:
- RedisType
- Defined in:
- lib/familia/features/quantization.rb,
lib/familia/features.rb,
lib/familia/features/safe_dump.rb,
lib/familia/features/expiration.rb
Overview
rubocop:disable all
Defined Under Namespace
Modules: Expiration, Quantization, SafeDump
Instance Attribute Summary collapse
-
#features_enabled ⇒ Object
readonly
Returns the value of attribute features_enabled.
Instance Method Summary collapse
Instance Attribute Details
#features_enabled ⇒ Object (readonly)
Returns the value of attribute features_enabled.
8 9 10 |
# File 'lib/familia/features.rb', line 8 def features_enabled @features_enabled end |
Instance Method Details
#feature(val = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/familia/features.rb', line 10 def feature(val = nil) @features_enabled ||= [] # If there's a value provied check that it's a valid feature if val val = val.to_sym raise Familia::Problem, "Unsupported feature: #{val}" unless Familia::Base.features.key?(val) # If the feature is already enabled, do nothing but log about it if @features_enabled.member?(val) Familia.warn "[Familia::Settings] feature already enabled: #{val}" return end Familia.trace :FEATURE, nil, "#{self} includes #{val.inspect}", caller(1..1) if Familia.debug? klass = Familia::Base.features[val] # Extend the Familia::Base subclass (e.g. Customer) with the feature module include klass # NOTE: We may also want to extend Familia::RedisType here so that we can # call safe_dump on relations fields (e.g. list, set, zset, hashkey). Or # maybe that only makes sense for hashk/object relations. # # We'd need to avoid it getting included multiple times (i.e. once for each # Familia::Horreum subclass that includes the feature). # Now that the feature is loaded successfully, add it to the list # enabled features for Familia::Base classes. @features_enabled << val end features_enabled end |