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, #fetchable_fields, inclusions, resolve_relationship_names_to_relations, updatable_fields

Instance Method Details

#optionsObject

rubocop:todo Metrics/MethodLength


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/resources/api/v2/request_resource.rb', line 41

def options # rubocop:todo Metrics/AbcSize
  # 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 { |attribute, value| attrs[attribute.name.to_s] = value unless value.nil? }
    _model
      .
      .association_value_pairs(.association_details)
      .each { |association, value| attrs[association.name.to_s] = value unless value.nil? }
  end
end

#pre_capture_pool_idObject


65
66
67
# File 'app/resources/api/v2/request_resource.rb', line 65

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


61
62
63
# File 'app/resources/api/v2/request_resource.rb', line 61

def primer_panel_id
  _model..primer_panel_id
end