Module: Stale::Interface
Instance Method Summary
collapse
#add_dependency_to_list, #dependency_key_for_collection, #dependency_key_for_instance, #expire_dependencies, #expire_dependencies_from_list, #register_dependencies, #register_dependency
Instance Method Details
#collection_from_key(model_key) ⇒ Object
27
28
29
|
# File 'lib/stale/interface.rb', line 27
def collection_from_key(model_key)
key_for_model(model_key.split(Stale.configuration[:model_key_separator], 2).first)
end
|
#key_as_string(key_array) ⇒ Object
19
20
21
|
# File 'lib/stale/interface.rb', line 19
def key_as_string(key_array)
Array(key_array).join(Stale.configuration[:key_separator])
end
|
#key_for_collection(collection) ⇒ Object
15
16
17
|
# File 'lib/stale/interface.rb', line 15
def key_for_collection(collection)
collection.is_a?(Class) ? collection.name.underscore : collection
end
|
#key_for_model(collection, id = nil, *args) ⇒ Object
11
12
13
|
# File 'lib/stale/interface.rb', line 11
def key_for_model(collection, id = nil, *args)
[key_for_collection(collection), id, *args].join(Stale.configuration[:model_key_separator])
end
|
#key_for_parameters(parameters, controller) ⇒ Object
7
8
9
|
# File 'lib/stale/interface.rb', line 7
def key_for_parameters(parameters, controller)
Stale.configuration.key_for_parameters(parameters, controller)
end
|
#models_from_key(key_array) ⇒ Object
23
24
25
|
# File 'lib/stale/interface.rb', line 23
def models_from_key(key_array)
key_array.select { |key_part| key_part.include?(Stale.configuration[:model_key_separator]) }
end
|