0.04
No commit activity in last 3 years
No release in over 3 years
Creates aliases of ActiveRecord named scopes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 4.7.5
~> 10.0

Runtime

 Project Readme

AliasScope

alias_scope is like alias_method for Active Record scopes

Installation

Add this line to your application's Gemfile:

gem 'alias_scope'

And then execute:

$ bundle

Or install it yourself as:

$ gem install alias_scope

Usage

class Address < ActiveRecord::Base
  scope :by_zip_code, -> zip_code { where("zip_code = ?", zip_code) }
  alias_scope :by_postal_code, :by_zip_code
end

Address.by_zip_code('90210')
Address.by_postal_code('90210')

You can also create multiple aliases by providing an array:

class Fabric < ActiveRecord::Base
  scope :flammable, -> { where(flammable: true) }
  alias_scope [:inflammable, :can_catch_on_fire], :flammable
end