Module: NullObjectAssociations::SingletonMethods
- Defined in:
- lib/null_object_associations.rb
Defined Under Namespace
Modules: ArrayMethodMissing
Instance Method Summary
collapse
Instance Method Details
#has_many(name, actions = {}) ⇒ Object
Also known as:
has_and_belongs_to_many
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/null_object_associations.rb', line 9
def has_many(name, actions = {})
if actions[:respond_to] == :any
associations = []
associations.extend ArrayMethodMissing
else
actions = coerce_actions(actions)
associations = build_associations(actions)
end
define_method(name) do
associations
end
end
|
#has_one(name) ⇒ Object
Also known as:
belongs_to
25
26
27
|
# File 'lib/null_object_associations.rb', line 25
def has_one(name)
define_method(name) { nil }
end
|