Module: EacRailsUtils::Models::InequalityQueries

Defined in:
lib/eac_rails_utils/models/inequality_queries.rb

Overview

Example:

Note: model Product has a attribute “foo” Date, Time or Number:

class Product
  include ::EacRailsUtils::Models::InequalityQueries

  add_inequality_queries(:foo)
end

This add the following scopes:

Product.by_foo_gt(value) # Equivalent to Product.where("foo > ?", value)
Product.by_foo_gteq(value) # Equivalent to Product.where("foo >= ?", value)
Product.by_foo_lt(value) # Equivalent to Product.where("foo < ?", value)
Product.by_foo_lteq(value) # Equivalent to Product.where("foo <= ?", value)

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


23
24
25
# File 'lib/eac_rails_utils/models/inequality_queries.rb', line 23

def included(base)
  base.extend(ClassMethods)
end