Class: ActiveMocker::ActiveRecord::Relationships::Relationship Private

Inherits:
Object
  • Object
show all
Defined in:
lib/active_mocker/active_record/relationships.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

BelongsTo, HasAndBelongsToMany, HasMany, HasOne

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Relationship

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.

Returns a new instance of Relationship.



35
36
37
38
# File 'lib/active_mocker/active_record/relationships.rb', line 35

def initialize(name, options={})
  @name = name
  @options = options.reduce(HashWithIndifferentAccess.new, :merge)
end

Instance Attribute Details

#nameObject (readonly)

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.



33
34
35
# File 'lib/active_mocker/active_record/relationships.rb', line 33

def name
  @name
end

Instance Method Details

#class_nameObject

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.



48
49
50
# File 'lib/active_mocker/active_record/relationships.rb', line 48

def class_name
  options[:class_name] || name.to_s.camelize.singularize
end

#foreign_keyObject

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.



52
53
54
# File 'lib/active_mocker/active_record/relationships.rb', line 52

def foreign_key
  options[:foreign_key] || name.to_s.foreign_key
end

#join_tableObject

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.



56
57
58
# File 'lib/active_mocker/active_record/relationships.rb', line 56

def join_table
  options[:join_table]
end

#optionsObject

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.



40
41
42
# File 'lib/active_mocker/active_record/relationships.rb', line 40

def options
  @options.symbolize_keys
end

#throughObject

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.



44
45
46
# File 'lib/active_mocker/active_record/relationships.rb', line 44

def through
  options[:through]
end