public
Description: Plugin for querying by dates on ActiveRecord models
Clone URL: git://github.com/joshuaclayton/acts_as_archivable.git
Fixed AAA to use named_scope correctly
joshuaclayton (author)
Thu Jul 24 07:12:06 -0700 2008
commit  3aced0f4f19de4f619a612a4af328996427b6236
tree    053a4563ad1f78dba850d044b6f2932c9f2a85bf
parent  dd4ee1b869606b7dafff3e54c70826610aa5ae5a
...
56
57
58
59
60
61
 
 
 
 
 
62
63
64
65
66
 
67
68
69
...
56
57
58
 
 
 
59
60
61
62
63
64
65
66
67
68
69
70
71
72
0
@@ -56,14 +56,17 @@ module Shooter #:nodoc:
0
         def self.included(base)
0
           base.extend ClassMethods
0
           if base.respond_to?(:named_scope)
0
- base.named_scope :by_date, lambda {|by_date| { :conditions => initial_conditions(by_date), :order => order }}
0
- base.named_scope :recent, lambda {|length_of_time| length_of_time ||= 1.year; recent_options(length_of_time) }
0
- base.named_scope :between, lambda {|start_date, end_date| { :conditions => between_conditions(start_date, end_date), :order => order }}
0
+ base.class_eval do
0
+ named_scope :by_date, lambda {|by_date| { :conditions => initial_conditions(by_date), :order => order }}
0
+ named_scope :recent, lambda {|*length_of_time| length_of_time = length_of_time.blank? ? 1.year: length_of_time; recent_options(length_of_time) }
0
+ named_scope :between, lambda {|start_date, end_date| { :conditions => between_conditions(start_date, end_date), :order => order }}
0
+ end
0
           else
0
             base.extend WithScopeMethods
0
           end
0
         end
0
         
0
+
0
         module WithScopeMethods
0
           def by_date(by_date, options ={})
0
             with_scope(:find => {:conditions => initial_conditions(by_date), :order => order}) do

Comments

    No one has commented yet.