Module: Zaikio::Directory::Asset

Extended by:
ActiveSupport::Concern
Included in:
Machine, Software, Specialist
Defined in:
lib/zaikio/directory/asset.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/zaikio/directory/asset.rb', line 22

def destroy
  if Zaikio::Directory.current_token_data.subject_type == "Organization"
    self.class.request(:delete,
                       "#{collection_name}/#{id}/#{singular_name}_ownership")
  else
    org_path = "person/organizations/#{owner_id || organization_id}"
    self.class.request(:delete,
                       "#{org_path}/#{collection_name}/#{id}/#{singular_name}_ownership")
  end
end

#make_organization_ownerObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/zaikio/directory/asset.rb', line 11

def make_organization_owner
  if Zaikio::Directory.current_token_data.subject_type == "Organization"
    self.class.request(:post,
                       "#{collection_name}/#{id}/#{singular_name}_ownership")
  else
    org_path = "person/organizations/#{organization_id}"
    self.class.request(:post,
                       "#{org_path}/#{collection_name}/#{id}/#{singular_name}_ownership")
  end
end

#specificationObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/zaikio/directory/asset.rb', line 33

def specification
  prefix = if Zaikio::Directory.current_token_data.subject_type == "Person"
             "person/organizations/#{owner_id || organization_id}/"
           else
             ""
           end
  self.class.request(:get,
                     "#{prefix}#{collection_name}/#{id}/#{singular_name}_specification")
      &.body&.dig("data")
end