Class: Anchor::JSONSchema::Resource

Inherits:
Resource
  • Object
show all
Defined in:
lib/anchor/json_schema/resource.rb

Instance Attribute Summary

Attributes inherited from Resource

#resource_klass

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Anchor::Resource

Instance Method Details

#express(context: {}, include_all_fields:, exclude_fields:) ⇒ Object

[View source]

3
4
5
6
7
8
9
10
11
12
# File 'lib/anchor/json_schema/resource.rb', line 3

def express(context: {}, include_all_fields:, exclude_fields:)
  included_fields = schema_fetchable_fields(context:, include_all_fields:)
  included_fields -= exclude_fields if exclude_fields

  properties = [id_property, type_property] +
    Array.wrap(anchor_attributes_properties(included_fields:)) +
    Array.wrap(anchor_relationships_property(included_fields:))

  Anchor::Types::Object.new(properties)
end