Module: ActiveRecord::Arrangeable

Defined in:
lib/active_record_arrangeable/version.rb,
lib/active_record_arrangeable/arrangeable.rb,
lib/active_record_arrangeable/arrange_service.rb

Defined Under Namespace

Modules: ArrangeClassMethods Classes: ArrangeService

Constant Summary collapse

VERSION =
'0.1.5'.freeze

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/active_record_arrangeable/arrangeable.rb', line 3

def self.included(base)
  base.extend ArrangeClassMethods

  base.class_eval do
    ##
    # Adds custom arrange as scope
    #
    private_class_method def self.arrange_by(attr, arrange)
      scope "arrange_with_#{attr}", arrange
    end
  end

  return unless defined?(ActiveRecord::Relation)

  ActiveRecord::Relation.send :include, ArrangeClassMethods
end