Class: PassiveRecord::Associations::HasManyRelation
- Inherits:
-
HasOneRelation
show all
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/passive_record/associations/has_many.rb
Instance Attribute Summary
Attributes inherited from Relation
#association, #parent_model
Instance Method Summary
collapse
#child_class, #create, #id, #lookup, #parent_class_name, #parent_model_id_field
Instance Method Details
#<<(child) ⇒ Object
34
35
36
37
|
# File 'lib/passive_record/associations/has_many.rb', line 34
def <<(child)
child.send(parent_model_id_field + "=", parent_model.id)
all
end
|
#all ⇒ Object
17
18
19
|
# File 'lib/passive_record/associations/has_many.rb', line 17
def all
child_class.where(parent_model_id_field => parent_model.id).all
end
|
#all?(*args) ⇒ Boolean
22
23
24
|
# File 'lib/passive_record/associations/has_many.rb', line 22
def all?(*args)
all.all?(*args)
end
|
#empty? ⇒ Boolean
26
27
28
|
# File 'lib/passive_record/associations/has_many.rb', line 26
def empty?
all.empty?
end
|
#singular? ⇒ Boolean
39
40
41
|
# File 'lib/passive_record/associations/has_many.rb', line 39
def singular?
false
end
|
#where(conditions = {}) ⇒ Object
30
31
32
|
# File 'lib/passive_record/associations/has_many.rb', line 30
def where(conditions={})
child_class.where(conditions.merge(parent_model_id_field.to_sym => parent_model.id))
end
|