class Pakyow::Presenter::Composers::Component
@api private
Attributes
component_path[R]
Public Class Methods
follow_path(path, view)
click to toggle source
Follow the path to find the correct component.
# File lib/pakyow/presenter/composers/component.rb, line 67 def follow_path(path, view) path = path.dup while step = path.shift view = view.components[step] end view end
new(view_path, component_path, app:, labels: {})
click to toggle source
Calls superclass method
# File lib/pakyow/presenter/composers/component.rb, line 21 def initialize(view_path, component_path, app:, labels: {}) super(view_path, app: app) @component_path = component_path @labels = labels end
Public Instance Methods
finalize(view)
click to toggle source
# File lib/pakyow/presenter/composers/component.rb, line 35 def finalize(view) if @labels.any? if view.frozen? view = view.soft_copy end @labels.each_pair do |key, value| view.object.set_label(key, value) end end view end
key()
click to toggle source
# File lib/pakyow/presenter/composers/component.rb, line 27 def key @view_path + "::" + @component_path.join("::") end
marshal_dump()
click to toggle source
# File lib/pakyow/presenter/composers/component.rb, line 49 def marshal_dump { app: @app, view_path: @view_path, component_path: @component_path } end
marshal_load(state)
click to toggle source
# File lib/pakyow/presenter/composers/component.rb, line 57 def marshal_load(state) @labels = {} state.each do |key, value| instance_variable_set(:"@#{key}", value) end end
post_process(view)
click to toggle source
# File lib/pakyow/presenter/composers/component.rb, line 31 def post_process(view) self.class.follow_path(@component_path, view) end