Class: Presently::Resolver

Inherits:
Live::Resolver
  • Object
show all
Defined in:
lib/presently/application.rb

Overview

Extends Live::Resolver to pass shared state to views on construction.

When the browser reconnects via WebSocket, the resolver creates new view instances with the shared PresentationController so all clients stay in sync.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**state) ⇒ Resolver

Initialize a new resolver with shared state.



24
25
26
27
# File 'lib/presently/application.rb', line 24

def initialize(**state)
	super()
	@state = state
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



30
31
32
# File 'lib/presently/application.rb', line 30

def state
  @state
end

Instance Method Details

#call(id, data) ⇒ Object

Resolve a client-side element to a server-side instance with shared state.



36
37
38
39
40
# File 'lib/presently/application.rb', line 36

def call(id, data)
	if klass = @allowed[data[:class]]
		return klass.new(id, data, **@state)
	end
end

#The shared state passed to view constructors.=(sharedstatepassedtoviewconstructors. = (value)) ⇒ Object



30
# File 'lib/presently/application.rb', line 30

attr :state