module Motion::Component::Rendering

Constants

STATE_EXCLUDED_IVARS

Public Instance Methods

awaiting_forced_rerender?() click to toggle source
# File lib/motion/component/rendering.rb, line 37
def awaiting_forced_rerender?
  @_awaiting_forced_rerender
end
render_hash() click to toggle source
  • This can be overwritten.

  • It will not be sent to the client.

  • If it doesn't change every time the component's state changes, things may fall out of sync unless you also call `#rerender!`

# File lib/motion/component/rendering.rb, line 45
def render_hash
  Motion.serializer.weak_digest(self)
end
render_in(view_context) click to toggle source
Calls superclass method
# File lib/motion/component/rendering.rb, line 49
def render_in(view_context)
  raise BlockNotAllowedError, self if block_given?

  html =
    _run_action_callbacks(context: :render) {
      _clear_awaiting_forced_rerender!

      view_context.capture { super }
    }

  raise RenderAborted, self unless html

  Motion.markup_transformer.add_state_to_html(self, html)
end
rerender!() click to toggle source
# File lib/motion/component/rendering.rb, line 33
def rerender!
  @_awaiting_forced_rerender = true
end

Private Instance Methods

_clear_awaiting_forced_rerender!() click to toggle source
# File lib/motion/component/rendering.rb, line 66
def _clear_awaiting_forced_rerender!
  @_awaiting_forced_rerender = false
end
marshal_dump() click to toggle source
# File lib/motion/component/rendering.rb, line 70
def marshal_dump
  (instance_variables - STATE_EXCLUDED_IVARS)
    .map { |ivar| [ivar, instance_variable_get(ivar)] }
    .to_h
end
marshal_load(instance_variables) click to toggle source
# File lib/motion/component/rendering.rb, line 76
def marshal_load(instance_variables)
  instance_variables.each do |ivar, value|
    instance_variable_set(ivar, value)
  end
end