Class: GrapeSwagger::Jsonapi::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/grape_jsonapi/parser.rb

Direct Known Subclasses

FastJsonapi::Parser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, endpoint) ⇒ Parser

Returns a new instance of Parser.



8
9
10
11
# File 'lib/grape_jsonapi/parser.rb', line 8

def initialize(model, endpoint)
  @model = model
  @endpoint = endpoint
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



6
7
8
# File 'lib/grape_jsonapi/parser.rb', line 6

def endpoint
  @endpoint
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/grape_jsonapi/parser.rb', line 6

def model
  @model
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
# File 'lib/grape_jsonapi/parser.rb', line 13

def call
  schema = default_schema
  schema = enrich_with_attributes(schema)
  schema = enrich_with_relationships(schema)
  schema.deep_merge!(model.additional_schema) if model.respond_to?(:additional_schema)

  schema
end