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.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



33
34
35
# File 'lib/iknow_cache.rb', line 33

def config
  @config
end

Class Method Details

.cacheObject



39
40
41
# File 'lib/iknow_cache.rb', line 39

def cache
  config.cache
end

.configure!(&block) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
# File 'lib/iknow_cache.rb', line 24

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)


20
21
22
# File 'lib/iknow_cache.rb', line 20

def self.configured?
  ! config.nil?
end

.loggerObject



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

def logger
  config.logger
end

.merge_options(parent_options, options) ⇒ Object



284
285
286
287
288
289
290
291
292
# File 'lib/iknow_cache.rb', line 284

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)


44
45
46
47
48
# File 'lib/iknow_cache.rb', line 44

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