Module: ReactEmailRails::RenderProtocol

Extended by:
RenderProtocol
Included in:
RenderProtocol
Defined in:
lib/react_email_rails/render_protocol.rb

Instance Method Summary collapse

Instance Method Details

#compatible_metadata?(body) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/react_email_rails/render_protocol.rb', line 18

def compatible_metadata?(body)
  body["protocolVersion"] == RENDER_PROTOCOL_VERSION &&
    body["packageVersion"] == VERSION
end

#compatible_response?(body) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/react_email_rails/render_protocol.rb', line 14

def compatible_response?(body)
  body["ok"] == true && compatible_metadata?(body)
end

#healthy_result?(result) ⇒ Boolean

Callers keep their own rescue to also cover failures obtaining the result.

Returns:

  • (Boolean)


10
11
12
# File 'lib/react_email_rails/render_protocol.rb', line 10

def healthy_result?(result)
  result.status.success? && compatible_response?(JSON.parse(result.stdout))
end

#mismatch_message(body) ⇒ Object



23
24
25
26
# File 'lib/react_email_rails/render_protocol.rb', line 23

def mismatch_message(body)
  "renderer version mismatch: expected react-email-rails #{VERSION} protocol #{RENDER_PROTOCOL_VERSION}, " \
    "got package #{body["packageVersion"].inspect} protocol #{body["protocolVersion"].inspect}"
end