module SnFoil::Contexts::IndexContext

Public Instance Methods

index(params: {}, entity: nil, **options) click to toggle source
# File lib/sn_foil/contexts/index_context.rb, line 18
def index(params: {}, entity: nil, **options)
  new(entity).index(**options, params: params)
end
searcher(klass = nil) click to toggle source
# File lib/sn_foil/contexts/index_context.rb, line 22
def searcher(klass = nil)
  @i_searcher = klass
end
setup_index(method = nil, **options, &block) click to toggle source
# File lib/sn_foil/contexts/index_context.rb, line 26
def setup_index(method = nil, **options, &block)
  raise ArgumentError, '#setup_index requires either a method name or a block' if method.nil? && block.nil?

  (@i_setup_index_hooks ||= []) << { method: method, block: block, if: options[:if], unless: options[:unless] }
end
setup_index_hooks() click to toggle source
# File lib/sn_foil/contexts/index_context.rb, line 37
def setup_index_hooks
  self.class.i_setup_index_hooks || []
end

Private Instance Methods

before_setup_index(**options) click to toggle source
# File lib/sn_foil/contexts/index_context.rb, line 56
def before_setup_index(**options)
  options = setup(**options)
  options = setup_hooks.reduce(options) { |opts, hook| run_hook(hook, opts) }
  options = setup_index(**options)
  setup_index_hooks.reduce(options) { |opts, hook| run_hook(hook, opts) }
end