public
Description: include Enumerable
Homepage: http://defunkt.github.com/ambition
Clone URL: git://github.com/defunkt/ambition.git
100644 101 lines (88 sloc) 2.575 kb
1
2
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
##
# The format of the documentation herein is:
#
# >> method with block
# => methods on this class called by Ambition (with arguments)
#
module Ambition
  module Adapters
    module <%= adapter_module %>
      class Select < Base
        # >> select { |u| u.name == 'chris' }
        # => #call(:name)
        def call(method)
          raise "Not implemented."
        end
 
        # >> select { |u| u.name.downcase == 'chris' }
        # => #call(:name, :downcase)
        def chained_call(*methods)
          # An idiom here is to call the chained method and pass it
          # the first method.
          #
          # if respond_to? methods[1]
          # send(methods[1], methods[0])
          # end
          #
          # In the above example, this translates to calling:
          #
          # #downcase(:name)
          #
          raise "Not implemented."
        end
 
        # &&
        # >> select { |u| u.name == 'chris' && u.age == 22 }
        # => #both( processed left side, processed right side )
        def both(left, right)
          raise "Not implemented."
        end
 
        # ||
        # >> select { |u| u.name == 'chris' || u.age == 22 }
        # => #either( processed left side, processed right side )
        def either(left, right)
          raise "Not implemented."
        end
 
        # >> select { |u| u.name == 'chris' }
        # => #==( call(:name), 'chris' )
        def ==(left, right)
          raise "Not implemented."
        end
 
        # !=
        # >> select { |u| u.name != 'chris' }
        # => #not_equal( call(:name), 'chris' )
        def not_equal(left, right)
          raise "Not implemented."
        end
 
        # >> select { |u| u.name =~ 'chris' }
        # => #=~( call(:name), 'chris' )
        def =~(left, right)
          raise "Not implemented."
        end
 
        # !~
        # >> select { |u| u.name !~ 'chris' }
        # => #not_regexp( call(:name), 'chris' )
        def not_regexp(left, right)
          raise "Not implemented."
        end
 
        ##
        # Etc.
        def <(left, right)
          raise "Not implemented."
        end
 
        def >(left, right)
          raise "Not implemented."
        end
 
        def >=(left, right)
          raise "Not implemented."
        end
 
        def <=(left, right)
          raise "Not implemented."
        end
 
        # >> select { |u| [1, 2, 3].include? u.id }
        # => #include?( [1, 2, 3], call(:id) )
        def include?(left, right)
          raise "Not implemented."
        end
      end
    end
  end
end