Class: Interfacets::Server::Facets::Schema::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/interfacets/server/facets/schema/serializer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(facets:) ⇒ Serializer

Returns a new instance of Serializer.



13
14
15
16
# File 'lib/interfacets/server/facets/schema/serializer.rb', line 13

def initialize(facets:)
  @facets = facets
  @schema = { views: {}, entities: {}, apis: {} }
end

Instance Attribute Details

#facets ⇒ Object (readonly)

Returns the value of attribute facets.



12
13
14
# File 'lib/interfacets/server/facets/schema/serializer.rb', line 12

def facets
  @facets
end

#schema ⇒ Object (readonly)

Returns the value of attribute schema.



12
13
14
# File 'lib/interfacets/server/facets/schema/serializer.rb', line 12

def schema
  @schema
end

Class Method Details

.call ⇒ Object



8
9
10
# File 'lib/interfacets/server/facets/schema/serializer.rb', line 8

def self.call(...)
  new(...).call
end

Instance Method Details

#call ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/interfacets/server/facets/schema/serializer.rb', line 18

def call
  facets.each do |facet|
    config = facet.client_config

    schema[:views][config.view.name] = {
      body: write_source(config.view.block),
    }

    schema[:entities][config.entity.name] = {
      api_type: config.api.name,
      body: write_source(config.entity.block),
    }

    schema[:apis][config.api.name] = {
      body: write_source(config.api.block),
    }
  end

  schema
end