Class: Anchor::JSONSchema::Resource

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

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Resource

Returns a new instance of Resource.



5
6
7
# File 'lib/anchor/json_schema/resource.rb', line 5

def initialize(klass)
  @klass = klass
end

Instance Method Details

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



9
10
11
12
# File 'lib/anchor/json_schema/resource.rb', line 9

def express(context: {}, include_all_fields:)
  t = Anchor::Inference::JSONAPI::ReadType.infer(@klass, context:, include_all_fields:).omit(["meta", "links"])
  t["relationships"].type.properties.count > 0 ? t : t.omit(["relationships"])
end