class PDC::Resource::Associations::HasMany

Public Class Methods

new(*args) click to toggle source
# 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

Public Instance Methods

load() click to toggle source
# File lib/pdc/resource/associations/has_many.rb, line 15
def load
  self
end

Private Instance Methods

parent_path() click to toggle source
# File lib/pdc/resource/associations/has_many.rb, line 21
def parent_path
  parent.class.model_name.element.pluralize
end