Class: Anchor::Inference::JSONAPI::Infer::Resource

Inherits:
Base
  • Object
show all
Defined in:
lib/anchor/inference/jsonapi/infer/resource.rb

Instance Method Summary collapse

Methods inherited from Base

infer, #initialize

Constructor Details

This class inherits a constructor from Anchor::Inference::JSONAPI::Infer::Base

Instance Method Details

#inferObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/anchor/inference/jsonapi/infer/resource.rb', line 7

def infer
  shell = Shell.infer(@klass)
  annotated = AnchorDef.infer(@klass)

  model = delegated_attrs(attributes) + attributes + relationships
  inferred = (model + shell).pick(shell.keys)

  fallback = rbs.pick(inferred.pick_by_value(unknown.singleton_class).keys)
  result = annotated + inferred.overwrite(fallback, keep_description: :left)

  anchor_comments.wrap(result)
end