Class: Pakyow::Data::Sources::Relational::Associations::HasMany Private

Inherits:
Pakyow::Data::Sources::Relational::Association show all
Defined in:
lib/pakyow/data/sources/relational/associations/has_many.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.

Instance Attribute Summary collapse

Attributes inherited from Pakyow::Data::Sources::Relational::Association

#associated_source, #associated_source_name, #name, #query, #source

Instance Method Summary collapse

Methods inherited from Pakyow::Data::Sources::Relational::Association

#dependent_source_names, #internal!, #internal?

Constructor Details

#initialize(as:, dependent:, **common_args) ⇒ HasMany

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 HasMany.



16
17
18
19
20
21
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 16

def initialize(as:, dependent:, **common_args)
  super(**common_args)

  @associated_name = Support.inflector.pluralize(as).to_sym
  @dependent = dependent
end

Instance Attribute Details

#associated_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.



14
15
16
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 14

def associated_name
  @associated_name
end

#dependentObject (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.



14
15
16
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 14

def dependent
  @dependent
end

Instance Method Details

#associated_query_fieldObject

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.



43
44
45
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 43

def associated_query_field
  :"#{Support.inflector.singularize(@associated_name)}_#{@source.primary_key_field}"
end

#dependents?Boolean

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:

  • (Boolean)


47
48
49
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 47

def dependents?
  true
end

#foreign_key_fieldObject

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.



35
36
37
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 35

def foreign_key_field
  associated_query_field
end

#query_fieldObject

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.



39
40
41
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 39

def query_field
  @source.primary_key_field
end

#result_typeObject

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.



31
32
33
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 31

def result_type
  :many
end

#specific_typeObject

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.



27
28
29
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 27

def specific_type
  :has_many
end

#typeObject

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.



23
24
25
# File 'lib/pakyow/data/sources/relational/associations/has_many.rb', line 23

def type
  :has
end