3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/fake_arel/rails_3_finders.rb', line 3
def self.included(base)
base.class_eval do
named_scope :offset, lambda {|offset| {:offset => offset}}
named_scope :limit, lambda {|limit| {:limit => limit}}
named_scope :includes, lambda { |*includes| { :include => includes }}
named_scope :select, lambda {|*select| {:select => select.join(',') }}
named_scope :order, lambda {|*order| {:order => order.join(',') }}
named_scope :joins, lambda {|*join| {:joins => join } if join[0]}
named_scope :from, lambda {|*from| {:from => from }}
named_scope :having, lambda {|*having| {:having => having }}
named_scope :group, lambda {|*group| {:group => group }}
named_scope :readonly, lambda {|readonly| {:readonly => readonly }}
named_scope :lock, lambda {|lock| {:lock => lock }}
__where_fn = lambda do |*where|
if where.is_a?(Array) and where.size == 1
{:conditions => where.first}
else
{:conditions => where}
end
end
named_scope :where, __where_fn
end
end
|