Module: Sequel::Unicache::Configuration::ClassMethods

Included in:
Model
Defined in:
lib/sequel/unicache/configuration.rb

Defined Under Namespace

Classes: Utils

Instance Method Summary collapse

Instance Method Details

#unicache_class_configurationObject



58
59
60
61
# File 'lib/sequel/unicache/configuration.rb', line 58

def unicache_class_configuration
  initialize_unicache
  @unicache_class_configuration
end

#unicache_configurationsObject



63
64
65
66
# File 'lib/sequel/unicache/configuration.rb', line 63

def unicache_configurations
  initialize_unicache
  @unicache_key_configurations
end

#unicache_enabled_for?(*key) ⇒ Boolean

config.enabled must be true, config.cache must be existed

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
# File 'lib/sequel/unicache/configuration.rb', line 49

def unicache_enabled_for? *key # config.enabled must be true, config.cache must be existed
  if key.first.is_a?(Configuration)
    config = key.first
  else
    config = unicache_for(*key)
  end
  config.cache && config.enabled if config
end

#unicache_for(*key, fuzzy: false) ⇒ Object

Read configuration for specified model



38
39
40
41
42
43
44
45
46
47
# File 'lib/sequel/unicache/configuration.rb', line 38

def unicache_for *key, fuzzy: false
  initialize_unicache
  if fuzzy
    config = Utils.fuzzy_search_for key, @unicache_key_configurations
  else
    key = Utils.normalize_key_for_unicache key
    config = @unicache_key_configurations[key]
  end
  config
end