Sha256: 71eabd812eb797eb85cfc176014488ed99b128e9974893c106b19b06598d5e41
Contents?: true
Size: 709 Bytes
Versions: 2
Compression:
Stored size: 709 Bytes
Contents
module ActiveCollection module Order def self.included(mod) mod.extend ClassMethods mod.class_eval do find_scope :order_options end end def order @order ||= self.class.default_order end def order_by(order) ac = dup ac.order_by! order ac end def order_by!(order) raise_if_loaded @order = order end def order_options order ? { :order => order } : {} end module ClassMethods def order_by(order = "id ASC") write_inheritable_attribute(:default_order, order) end def default_order read_inheritable_attribute(:default_order) || nil end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
martinemde-active_collection-0.2.0 | lib/active_collection/order.rb |
active_collection-0.2.0 | lib/active_collection/order.rb |