Module: NoBrainer::Criteria::Extend

Extended by:
ActiveSupport::Concern
Defined in:
lib/no_brainer/criteria/extend.rb

Instance Method Summary collapse

Instance Method Details

#extend(*modules, &block) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/no_brainer/criteria/extend.rb', line 6

def extend(*modules, &block)
  options = modules.extract_options!
  modules << Module.new(&block) if block

  return super(*modules) if options[:original_behavior]
  chain(:extend => [modules])
end

#merge!(criteria, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/no_brainer/criteria/extend.rb', line 14

def merge!(criteria, options={})
  super.tap do
    @options[:extend].to_a.each { |modules| extend(*modules, :original_behavior => true) }
  end
end