Module: ScopeHound::FilterScopable

Extended by:
ActiveSupport::Concern
Included in:
FilterProxy
Defined in:
app/models/concerns/scope_hound/filter_scopable.rb

Overview

Helps to generate filter concerns

Instance Method Summary collapse

Instance Method Details

#filter_scope(name, block) ⇒ Object



8
9
10
11
12
13
14
# File 'app/models/concerns/scope_hound/filter_scopable.rb', line 8

def filter_scope(name, block)
  define_method(name) do |filter_value|
    return self if filter_value.blank?

    instance_exec(filter_value, &block)
  end
end

#filter_scope_path_for(scope, path = nil) ⇒ Object



16
17
18
19
# File 'app/models/concerns/scope_hound/filter_scopable.rb', line 16

def filter_scope_path_for(scope, path = nil)
  path = scope.to_s if path.nil?
  filter_scopes_paths[scope] = path
end

#filter_scopes_pathsObject



21
22
23
# File 'app/models/concerns/scope_hound/filter_scopable.rb', line 21

def filter_scopes_paths
  @filter_scopes_paths ||= {}
end