Class: Api::V2::RequestResource

Inherits:
BaseResource
  • Object
show all
Defined in:
app/resources/api/v2/request_resource.rb

Overview

Provides a JSON API representation of request See: jsonapi-resources.com/ for JSONAPI::Resource documentation

Instance Method Summary collapse

Methods inherited from BaseResource

apply_includes, default_includes, inclusions, resolve_relationship_names_to_relations, updatable_fields

Instance Method Details

#optionsObject

Custom methods These shouldn't be used for business logic, and a more about I/O and isolating implementation details.


36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/resources/api/v2/request_resource.rb', line 36

def options
  # We need to pass in the attribute details here, as eager loading the metadata just instantiates
  # Request::Metadata
  # TODO: Nuke the separate metadata classes and metaprogramming
  {}.tap do |attrs|
     = _model.class::Metadata
    _model..attribute_value_pairs(.attribute_details).each do |attribute, value|
      attrs[attribute.name.to_s] = value unless value.nil?
    end
    _model..association_value_pairs(.association_details).each do |association, value|
      attrs[association.name.to_s] = value unless value.nil?
    end
  end
end

#pre_capture_pool_idObject


56
57
58
# File 'app/resources/api/v2/request_resource.rb', line 56

def pre_capture_pool_id
  _model.pooled_request&.pre_capture_pool_id
end

#primer_panel_idObject

JSONAPI::Resource doesn't support has_one through relationships by default


52
53
54
# File 'app/resources/api/v2/request_resource.rb', line 52

def primer_panel_id
  _model..primer_panel_id
end