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

Instance Method Summary collapse

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

#collectionsObject

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

#relationshipsObject

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_relationshipsObject

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