Module: ActiveMocker::ActiveRecord::Relationships Private
- Included in:
- Base
- Defined in:
- lib/active_mocker/active_record/relationships.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: ClassMethods Classes: BelongsTo, HasAndBelongsToMany, HasMany, HasOne, Relationship
Class Method Summary collapse
- .included(base) ⇒ Object private
Instance Method Summary collapse
- #belongs_to(*args) ⇒ Object private
- #collections ⇒ Object private
- #has_and_belongs_to_many(*args) ⇒ Object private
- #has_many(*args) ⇒ Object private
- #has_one(*args) ⇒ Object private
- #relationships ⇒ Object private
- #single_relationships ⇒ Object private
Class Method Details
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/active_mocker/active_record/relationships.rb', line 9 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#belongs_to(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 95 |
# File 'lib/active_mocker/active_record/relationships.rb', line 92 def belongs_to(*args) @belongs_to ||= [] @belongs_to.push BelongsTo.new(args.shift, args) end |
#collections ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/active_mocker/active_record/relationships.rb', line 28 def collections has_and_belongs_to_many + has_many end |
#has_and_belongs_to_many(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 104 |
# File 'lib/active_mocker/active_record/relationships.rb', line 101 def has_and_belongs_to_many(*args) @has_and_belongs_to_many ||= [] @has_and_belongs_to_many.push HasAndBelongsToMany.new(args.shift, args) end |
#has_many(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 79 |
# File 'lib/active_mocker/active_record/relationships.rb', line 76 def has_many(*args) @has_many ||= [] @has_many.push HasMany.new(args.shift, self.name, args) end |
#has_one(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 87 |
# File 'lib/active_mocker/active_record/relationships.rb', line 84 def has_one(*args) @has_one ||= [] @has_one.push HasOne.new(args.shift, args) end |
#relationships ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 |
# File 'lib/active_mocker/active_record/relationships.rb', line 17 def relationships OpenStruct.new({has_many: @has_many ||= [], has_one: @has_one ||= [], belongs_to: @belongs_to ||= [], has_and_belongs_to_many: @has_and_belongs_to_many ||= []}) end |
#single_relationships ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/active_mocker/active_record/relationships.rb', line 24 def single_relationships belongs_to + has_one end |