Class: IknowCache

Inherits:
Object
  • Object
show all
Defined in:
lib/iknow_cache.rb,
lib/iknow_cache/railtie.rb,
lib/iknow_cache/version.rb

Defined Under Namespace

Classes: Cache, CacheGroup, Config, ConfigWriter, Railtie

Constant Summary collapse

VERSION =
'1.2.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



35
36
37
# File 'lib/iknow_cache.rb', line 35

def config
  @config
end

Class Method Details

.cacheObject



41
42
43
# File 'lib/iknow_cache.rb', line 41

def cache
  config.cache
end

.configure!(&block) ⇒ Object

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
# File 'lib/iknow_cache.rb', line 26

def self.configure!(&block)
  raise ArgumentError.new('Already configured!') if configured?

  config = Config.new
  ConfigWriter.new(config).instance_eval(&block)
  @config = config.freeze
end

.configured?Boolean

Returns:

  • (Boolean)


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

def self.configured?
  !config.nil?
end

.loggerObject



37
38
39
# File 'lib/iknow_cache.rb', line 37

def logger
  config.logger
end

.merge_options(parent_options, options) ⇒ Object



317
318
319
320
321
322
323
324
325
# File 'lib/iknow_cache.rb', line 317

def self.merge_options(parent_options, options)
  if parent_options.blank?
    options
  elsif options.blank?
    parent_options
  else
    parent_options.merge(options)
  end
end

.register_group(name, key_name, default_options: nil, static_version: 1) {|group| ... } ⇒ Object

Yields:

  • (group)


46
47
48
49
50
# File 'lib/iknow_cache.rb', line 46

def self.register_group(name, key_name, default_options: nil, static_version: 1)
  group = CacheGroup.new(nil, name, key_name, default_options, static_version)
  yield group if block_given?
  group
end