Class: Pakyow::Presenter::Composers::Component Private

Inherits:
View
  • Object
show all
Defined in:
lib/pakyow/presenter/composers/component.rb

Overview

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.

API:

  • private

Constant Summary

Constants inherited from View

View::UNRETAINED_SIGNIFICANCE

Instance Attribute Summary collapse

Attributes inherited from View

#view_path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from View

#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.

API:

  • private



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_pathObject (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.

API:

  • private



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.

API:

  • private



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.

API:

  • private



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

#keyObject

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.

API:

  • private



27
28
29
# File 'lib/pakyow/presenter/composers/component.rb', line 27

def key
  @view_path + "::" + @component_path.join("::")
end

#marshal_dumpObject

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.

API:

  • private



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.

API:

  • private



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.

API:

  • private



31
32
33
# File 'lib/pakyow/presenter/composers/component.rb', line 31

def post_process(view)
  self.class.follow_path(@component_path, view)
end