Module: ActiveRecord::Extensions::FinderOptions::HavingOptionBackCompatibility

Defined in:
lib/ar-extensions/finder_options.rb

Overview

Before Version 2.3.0 there was no :having option Add this option to previous versions by overriding add_group! to accept a hash with keys :group and :having instead of just group this avoids having to completely rewrite dependent functions like construct_finder_sql_for_association_limiting

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

:nodoc:



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/ar-extensions/finder_options.rb', line 224

def self.extended(base)

  #for previous versions define having
  if ActiveRecord::VERSION::STRING < '2.3.0'
    base.extend ClassMethods

  #for 2.3.0+ alias our method to :add_group!
  else
    base.class_eval do
      class << self
        alias_method            :add_group_with_having!, :add_group!
      end
    end
  end
end