Module: ActiveRecord::Collections::Relation
- Included in:
- ActiveRecord::Collection
- Defined in:
- lib/active_record/collections/relation.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #all ⇒ Object
- #distinct(bool = true) ⇒ Object
- #distinct!(bool = true) ⇒ Object
- #group(*args) ⇒ Object
- #group!(*args) ⇒ Object
- #includes(*args) ⇒ Object
- #includes!(*args) ⇒ Object
- #joins(*args) ⇒ Object
- #joins!(*args) ⇒ Object
- #limit(*args, &block) ⇒ Object
- #limit!(*args, &block) ⇒ Object
- #load ⇒ Object
- #not(*args, &block) ⇒ Object
- #not!(*args, &block) ⇒ Object
- #offset(*args, &block) ⇒ Object
- #offset!(*args, &block) ⇒ Object
- #or(*args, &block) ⇒ Object
- #or!(*args, &block) ⇒ Object
- #order(*args, &block) ⇒ Object
- #order!(*args, &block) ⇒ Object
- #references(*table_names) ⇒ Object
- #references!(*table_names) ⇒ Object
- #reset(clear_total = true, clear_batches = true) ⇒ Object
- #reset!(clear_total = true, clear_batches = true) ⇒ Object
- #select(*args) ⇒ Object
- #select!(*args) ⇒ Object
- #where(*args, &block) ⇒ Object
- #where!(*args, &block) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/active_record/collections/relation.rb', line 4 def self.included(base) base.send :extend, ClassMethods end |
Instance Method Details
#all ⇒ Object
42 43 44 |
# File 'lib/active_record/collections/relation.rb', line 42 def all reset end |
#distinct(bool = true) ⇒ Object
60 61 62 |
# File 'lib/active_record/collections/relation.rb', line 60 def distinct(bool=true) dup.distinct!(bool) end |
#distinct!(bool = true) ⇒ Object
64 65 66 67 |
# File 'lib/active_record/collections/relation.rb', line 64 def distinct!(bool=true) @relation = relation.distinct(bool) self end |
#group(*args) ⇒ Object
105 106 107 |
# File 'lib/active_record/collections/relation.rb', line 105 def group(*args) dup.group!(*args) end |
#group!(*args) ⇒ Object
109 110 111 112 |
# File 'lib/active_record/collections/relation.rb', line 109 def group!(*args) @relation = relation.group(*args) self end |
#includes(*args) ⇒ Object
141 142 143 |
# File 'lib/active_record/collections/relation.rb', line 141 def includes(*args) dup.includes!(*args) end |
#includes!(*args) ⇒ Object
145 146 147 148 |
# File 'lib/active_record/collections/relation.rb', line 145 def includes!(*args) @relation = relation.includes(*args) self end |
#joins(*args) ⇒ Object
132 133 134 |
# File 'lib/active_record/collections/relation.rb', line 132 def joins(*args) dup.joins!(*args) end |
#joins!(*args) ⇒ Object
136 137 138 139 |
# File 'lib/active_record/collections/relation.rb', line 136 def joins!(*args) @relation = relation.joins(*args) self end |
#limit(*args, &block) ⇒ Object
114 115 116 |
# File 'lib/active_record/collections/relation.rb', line 114 def limit(*args, &block) dup.limit!(*args, &block) end |
#limit!(*args, &block) ⇒ Object
118 119 120 121 |
# File 'lib/active_record/collections/relation.rb', line 118 def limit!(*args, &block) @relation = relation.limit(*args, &block) self end |
#load ⇒ Object
46 47 48 49 |
# File 'lib/active_record/collections/relation.rb', line 46 def load relation.load records end |
#not(*args, &block) ⇒ Object
78 79 80 |
# File 'lib/active_record/collections/relation.rb', line 78 def not(*args, &block) dup.not!(*args, &block) end |
#not!(*args, &block) ⇒ Object
82 83 84 85 |
# File 'lib/active_record/collections/relation.rb', line 82 def not!(*args, &block) @relation = relation.where.not(*args, &block) self end |
#offset(*args, &block) ⇒ Object
123 124 125 |
# File 'lib/active_record/collections/relation.rb', line 123 def offset(*args, &block) dup.offset!(*args, &block) end |
#offset!(*args, &block) ⇒ Object
127 128 129 130 |
# File 'lib/active_record/collections/relation.rb', line 127 def offset!(*args, &block) @relation = relation.offset(*args, &block) self end |
#or(*args, &block) ⇒ Object
87 88 89 |
# File 'lib/active_record/collections/relation.rb', line 87 def or(*args, &block) dup.or!(*args, &block) end |
#or!(*args, &block) ⇒ Object
91 92 93 94 |
# File 'lib/active_record/collections/relation.rb', line 91 def or!(*args, &block) @relation = relation.or.where(*args, &block) self end |
#order(*args, &block) ⇒ Object
96 97 98 |
# File 'lib/active_record/collections/relation.rb', line 96 def order(*args, &block) dup.order!(*args, &block) end |
#order!(*args, &block) ⇒ Object
100 101 102 103 |
# File 'lib/active_record/collections/relation.rb', line 100 def order!(*args, &block) relation.order!(*args, &block) self end |
#references(*table_names) ⇒ Object
150 151 152 |
# File 'lib/active_record/collections/relation.rb', line 150 def references(*table_names) dup.references!(*table_names) end |
#references!(*table_names) ⇒ Object
154 155 156 157 |
# File 'lib/active_record/collections/relation.rb', line 154 def references!(*table_names) @relation = relation.references(*table_names) self end |
#reset(clear_total = true, clear_batches = true) ⇒ Object
165 166 167 |
# File 'lib/active_record/collections/relation.rb', line 165 def reset(clear_total=true, clear_batches=true) dup.reset!(clear_total, clear_batches) end |
#reset!(clear_total = true, clear_batches = true) ⇒ Object
169 170 171 172 173 174 175 176 177 178 |
# File 'lib/active_record/collections/relation.rb', line 169 def reset!(clear_total=true, clear_batches=true) @records = @record_ids = @size = nil @total_count = nil if clear_total relation.reset if clear_batches @is_batched = false relation.limit!(nil).offset!(nil) end self end |
#select(*args) ⇒ Object
51 52 53 |
# File 'lib/active_record/collections/relation.rb', line 51 def select(*args) dup.select!(*args) end |
#select!(*args) ⇒ Object
55 56 57 58 |
# File 'lib/active_record/collections/relation.rb', line 55 def select!(*args) @relation = relation.select(*args) self end |
#where(*args, &block) ⇒ Object
69 70 71 |
# File 'lib/active_record/collections/relation.rb', line 69 def where(*args, &block) dup.where!(*args, &block) end |
#where!(*args, &block) ⇒ Object
73 74 75 76 |
# File 'lib/active_record/collections/relation.rb', line 73 def where!(*args, &block) @relation = relation.where(*args, &block) self end |