Module: Pakyow::Presenter::Renderer::Behavior::PlaceInMode Private

Extended by:
Support::Extension
Defined in:
lib/pakyow/presenter/renderer/behavior/place_in_mode.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.perform(view, modes) ⇒ 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.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pakyow/presenter/renderer/behavior/place_in_mode.rb', line 40

def self.perform(view, modes)
  if modes.length == 1 && modes.first.to_sym == :default
    modes = view.info(:modes) || modes
  end

  modes.map!(&:to_sym)

  if view.object.is_a?(StringDoc::Node) && view.object.significant?(:mode) && !modes.include?(view.object.label(:mode))
    view.remove
  else
    view.object.each_significant_node(:mode, descend: true).select { |node|
      !modes.include?(node.label(:mode))
    }.each(&:remove)
  end
end