Module: HydraAttribute::Model::IdentityMap::ClassMethods

Defined in:
lib/hydra_attribute/model/identity_map.rb

Instance Method Summary collapse

Instance Method Details

#cache(key, value = nil) { ... } ⇒ Object

Proxy method to identity_map

Parameters:

  • key (String, Symbol)
  • value (NilClass, Object) (defaults to: nil)

Yields:

Returns:

  • (Object)


37
38
39
# File 'lib/hydra_attribute/model/identity_map.rb', line 37

def cache(key, value = nil, &block)
  identity_map.cache(key, value, &block)
end

#identity_mapHydraAttribute::IdentityMap

Identity map



19
20
21
# File 'lib/hydra_attribute/model/identity_map.rb', line 19

def identity_map
  ::HydraAttribute.cache(identity_map_cache_key) { ::HydraAttribute::IdentityMap.new }
end

#identity_map_cache_keySymbol

Identity map key

Returns:

  • (Symbol)


12
13
14
# File 'lib/hydra_attribute/model/identity_map.rb', line 12

def identity_map_cache_key
  @identity_map_cache_key ||= name.underscore.to_sym
end

#nested_identity_map(cache_key) ⇒ HydraAttribute::IdentityMap

Returns identity map object which is inserted into the default one

Parameters:

  • cache_key (Symbol)

Returns:



27
28
29
# File 'lib/hydra_attribute/model/identity_map.rb', line 27

def nested_identity_map(cache_key)
  identity_map.cache(cache_key) { ::HydraAttribute::IdentityMap.new }
end

#register_nested_cache(*cache_keys) ⇒ NilClass

Registers nested cache

Parameters:

  • cache_keys (Array<Symbol>)

Returns:

  • (NilClass)


45
46
47
48
49
# File 'lib/hydra_attribute/model/identity_map.rb', line 45

def register_nested_cache(*cache_keys)
  cache_keys.each do |cache_key|
    nested_cache_keys << cache_key
  end
end