Class: Interfacets::Server::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/interfacets/server/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity:, name:, registry:) ⇒ Api

Returns a new instance of Api.



7
8
9
10
11
# File 'lib/interfacets/server/api.rb', line 7

def initialize(entity:, name:, registry:)
  @entity = entity
  @name = name
  @registry = registry
end

Instance Attribute Details

#entity ⇒ Object (readonly)

Returns the value of attribute entity.



6
7
8
# File 'lib/interfacets/server/api.rb', line 6

def entity
  @entity
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/interfacets/server/api.rb', line 6

def name
  @name
end

#registry ⇒ Object (readonly)

Returns the value of attribute registry.



6
7
8
# File 'lib/interfacets/server/api.rb', line 6

def registry
  @registry
end

Instance Method Details

#handle(event) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/interfacets/server/api.rb', line 13

def handle(event)
  Shared::Entities::Bus
    .new(entity:)
    .handle(event:)

  if entity.channel.rendered?
    entity.channel.render_facet
  else
    emit("after_#{event.fetch("action")}", nesting: event.fetch("nesting"))
  end
end

#render ⇒ Object



25
26
27
# File 'lib/interfacets/server/api.rb', line 25

def render
  emit("after_load", nesting: ["root"])
end