Class: Guide::NodeView

Inherits:
Object
  • Object
show all
Defined in:
app/view_models/guide/node_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node:, bouncer:, diplomat:, node_path:) ⇒ NodeView

Returns a new instance of NodeView.



15
16
17
18
19
20
# File 'app/view_models/guide/node_view.rb', line 15

def initialize(node:, bouncer:, diplomat:, node_path:)
  @node = node
  @bouncer = bouncer
  @diplomat = diplomat
  @node_path = node_path
end

Instance Attribute Details

#node_pathObject (readonly)

Returns the value of attribute node_path.



13
14
15
# File 'app/view_models/guide/node_view.rb', line 13

def node_path
  @node_path
end

Instance Method Details

#current_localeObject



52
53
54
# File 'app/view_models/guide/node_view.rb', line 52

def current_locale
  @diplomat.current_locale
end

#locale_paramObject



56
57
58
# File 'app/view_models/guide/node_view.rb', line 56

def locale_param
  'temp_locale'
end

#multiple_formats?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/view_models/guide/node_view.rb', line 28

def multiple_formats?
  @node.formats.size > 1
end

#show_locale_switcher?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/view_models/guide/node_view.rb', line 48

def show_locale_switcher?
  @bouncer.user_is_privileged? && @diplomat.multiple_supported_locales?
end

#supported_localesObject



44
45
46
# File 'app/view_models/guide/node_view.rb', line 44

def supported_locales
  @diplomat.supported_locales
end

#template_locationObject



36
37
38
# File 'app/view_models/guide/node_view.rb', line 36

def template_location
  template || cell
end

#user_is_privileged?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'app/view_models/guide/node_view.rb', line 40

def user_is_privileged?
  @bouncer.user_is_privileged?
end

#uses_cells?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/view_models/guide/node_view.rb', line 32

def uses_cells?
  cell.present?
end

#visible_scenariosObject



22
23
24
25
26
# File 'app/view_models/guide/node_view.rb', line 22

def visible_scenarios
  @node.scenarios.select do |scenario_id, scenario|
    @bouncer.user_can_access?(scenario)
  end
end