Module: SearchApi::Search::Callbacks

Included in:
Base
Defined in:
lib/search_api/callbacks.rb

Constant Summary collapse

CALLBACKS =
%w(before_find_options)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.append_features(base) ⇒ Object

:nodoc:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/search_api/callbacks.rb', line 6

def self.append_features(base)  #:nodoc:
  super

  base.class_eval do
    %w(find_options).each do |method|
      alias_method_chain method, :callbacks
    end
  end

  CALLBACKS.each do |method|
    base.class_eval <<-"end_eval"
      def self.#{method}(*callbacks, &block)
        callbacks << block if block_given?
        write_inheritable_array(#{method.to_sym.inspect}, callbacks)
      end
    end_eval
  end
end

Instance Method Details

#before_find_optionsObject



30
31
# File 'lib/search_api/callbacks.rb', line 30

def before_find_options
end

#find_options_with_callbacksObject



25
26
27
28
# File 'lib/search_api/callbacks.rb', line 25

def find_options_with_callbacks
  callback(:before_find_options)
  find_options_without_callbacks
end