Module: UtilityScopes::Limited

Defined in:
lib/utility_scopes/limited.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(within) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/utility_scopes/limited.rb', line 4

def self.included(within)
  
  within.class_eval do
  
    # Provide default limit scope (can be overridden
    # if default_limit is called)
    named_scope :limited, lambda { |*num|
      { :limit => num.flatten.first || (defined?(per_page) ? per_page : 10) }
    }
    
    extend ClassMethods
  end
end