Class: PDC::Resource::Associations::HasMany

Inherits:
Association show all
Defined in:
lib/pdc/resource/associations/has_many.rb

Instance Attribute Summary

Attributes inherited from Association

#name, #parent

Attributes inherited from Relation

#klass, #params

Instance Method Summary collapse

Methods inherited from Relation

#all!, #count, #each, #find, #uri

Methods included from Pagination

#each_page

Methods included from Finder

#contents!, #find_one!

Methods included from Query

#where

Methods included from Logging

#logger

Constructor Details

#initialize(*args) ⇒ HasMany

Returns a new instance of HasMany.



6
7
8
9
10
11
12
13
# File 'lib/pdc/resource/associations/has_many.rb', line 6

def initialize(*args)
  super
  # This is the default uri. It can be overrided when defining a has_many association
  # if the uri is different with the default one.
  # E.g: has_many :releases, uri: 'rest_api/v1/releases/?product_version=:product_version_id'
  @options.reverse_merge!(uri: "#{parent_path}/:#{foreign_key}/#{@name}/(:#{primary_key})")
  @params[foreign_key] = parent.id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PDC::Resource::Relation

Instance Method Details

#loadObject



15
16
17
# File 'lib/pdc/resource/associations/has_many.rb', line 15

def load
  self
end