Module: ContextFilters::Context::GlobalFilters

Included in:
Global
Defined in:
lib/context-filters/context/global_filters.rb

Overview

simple access to global priority filters

Instance Method Summary collapse

Instance Method Details

#filter(priority, options = nil, &block) ⇒ Object

defines new filter for given priority and options

Parameters:

  • priority (nil, Object)

    has to correspond to one of the initialized priorities

  • options (Object) (defaults to: nil)

    the options to use for new filter

  • block (Proc)

    the transformation to use when the options match



33
34
35
# File 'lib/context-filters/context/global_filters.rb', line 33

def filter(priority, options = nil, &block)
  priority_filters.store(priority, options, &block)
end

#initialize_priority_filters(priority_filters) ⇒ Object

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.

sets up the priorities order for filters

Parameters:

  • priority_filters (Array)

    initialization param for PriorityFilters



23
24
25
# File 'lib/context-filters/context/global_filters.rb', line 23

def initialize_priority_filters(priority_filters)
  @priority_filters = ContextFilters::Filters::PriorityFilters.new(priority_filters)
end

#priority_filtersPriorityFilters

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 shared list of filters.

Returns:

  • (PriorityFilters)

    shared list of filters



16
17
18
# File 'lib/context-filters/context/global_filters.rb', line 16

def priority_filters
  @priority_filters ||= initialize_priority_filters(nil)
end