Class: PDC::V1::ReleaseVariant

Inherits:
Base
  • Object
show all
Defined in:
lib/pdc/v1/release_variant.rb

Instance Attribute Summary

Attributes included from Resource::RestApi

#url

Instance Method Summary collapse

Methods included from Resource::Scopes

#scoped

Methods included from Resource::Attributes

#[]=, #attributes=, #inspect

Methods included from Resource::Identity

#==, #as_json, #hash, #id, #id=, #id?, #uri

Methods included from Logging

#logger

Constructor Details

#initialize(attrs = {}) ⇒ ReleaseVariant

NOTE ReleaseVariant is different from other resources in the way its url is created so it requires special handling



16
17
18
19
20
21
22
# File 'lib/pdc/v1/release_variant.rb', line 16

def initialize(attrs = {})
  super

  instance_uri = self.class.resource_path + '/(:release)/(:uid)'
  instance_path = PDC::Resource::Path.new(instance_uri, attrs).expanded
  @url = connection.build_url(instance_path).to_s
end

Dynamic Method Handling

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

Instance Method Details

#cpeObject



24
25
26
# File 'lib/pdc/v1/release_variant.rb', line 24

def cpe
  VariantCpe.where(variant_uid: attributes[:uid]).first
end

#releaseObject



9
10
11
# File 'lib/pdc/v1/release_variant.rb', line 9

def release
  Release.find(attributes[:release])
end