Module: ContextFilters::Filters::Store

Included in:
Filters
Defined in:
lib/context-filters/filters/store.rb

Overview

Store filters

Instance Method Summary collapse

Instance Method Details

#empty?Boolean

Returns true if there are any rules stored, false otherwise.

Returns:

  • (Boolean)

    true if there are any rules stored, false otherwise



37
38
39
# File 'lib/context-filters/filters/store.rb', line 37

def empty?
  filters_store.empty?
end

#filtersObject

Array of already defined filters



32
33
34
# File 'lib/context-filters/filters/store.rb', line 32

def filters
  filters_store.keys
end

#filters_storeHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the filters storage.

Returns:

  • (Hash)

    the filters storage



17
18
19
# File 'lib/context-filters/filters/store.rb', line 17

def filters_store
  @filters_store ||= {}
end

#store(options = nil, &block) ⇒ Object

stores the block for given options, if the options have a block already the new one is added to the list

Parameters:

  • options (Object) (defaults to: nil)

    options for filtering blocks

  • block (Proc)

    block of code to add to the list of blocks for this options



26
27
28
29
# File 'lib/context-filters/filters/store.rb', line 26

def store(options = nil, &block)
  filters_store[options] ||= []
  filters_store[options] << block
end