Class: Pakyow::Presenter::Composers::Component Private
- Defined in:
- lib/pakyow/presenter/composers/component.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants inherited from View
Instance Attribute Summary collapse
- #component_path ⇒ Object readonly private
Attributes inherited from View
Class Method Summary collapse
-
.follow_path(path, view) ⇒ Object
private
Follow the path to find the correct component.
Instance Method Summary collapse
- #finalize(view) ⇒ Object private
-
#initialize(view_path, component_path, app:, labels: {}) ⇒ Component
constructor
private
A new instance of Component.
- #key ⇒ Object private
- #marshal_dump ⇒ Object private
- #marshal_load(state) ⇒ Object private
- #post_process(view) ⇒ Object private
Methods inherited from View
Constructor Details
#initialize(view_path, component_path, app:, labels: {}) ⇒ Component
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Component.
21 22 23 24 25 |
# 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 |
Instance Attribute Details
#component_path ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/pakyow/presenter/composers/component.rb', line 19 def component_path @component_path end |
Class Method Details
.follow_path(path, view) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Follow the path to find the correct component.
67 68 69 70 71 72 73 74 |
# 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 |
Instance Method Details
#finalize(view) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/pakyow/presenter/composers/component.rb', line 27 def key @view_path + "::" + @component_path.join("::") end |
#marshal_dump ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 52 53 54 55 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 60 61 62 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/pakyow/presenter/composers/component.rb', line 31 def post_process(view) self.class.follow_path(@component_path, view) end |