class Cascade::Statistics
Constants
- STORES
Attributes
store_repository[R]
Public Class Methods
new()
click to toggle source
# File lib/cascade/statistics.rb, line 15 def initialize @store_repository = {} end
Public Instance Methods
for(action)
click to toggle source
Returns statistics from store for passed action
@param action [Symbol] action name that will be used to access it
# File lib/cascade/statistics.rb, line 42 def for(action) @store_repository[action].store end
register_action(action, store, default_value = nil)
click to toggle source
Register statistics action with passed store
@param action [Symbol] action name that will be used to access it @param store [Symbol] type of using store @param default_value [Object] value that will be used as default for store @return [Object] instance of passed store
# File lib/cascade/statistics.rb, line 25 def register_action(action, store, default_value = nil) @store_repository[action] = defined_stores.fetch(store.to_sym) do default_store end.new(default_value) end
update(action, value = nil)
click to toggle source
Updates store action with passed value
@param action [Symbol] action name that will be used to access it @param value [Object] for updating store
# File lib/cascade/statistics.rb, line 35 def update(action, value = nil) @store_repository[action].update(value) end
Private Instance Methods
default_store()
click to toggle source
# File lib/cascade/statistics.rb, line 56 def default_store StatisticsStores::AbstractStore end
defined_stores()
click to toggle source
# File lib/cascade/statistics.rb, line 52 def defined_stores STORES end