Class: Guide::NodeView
- Inherits:
-
Object
- Object
- Guide::NodeView
- Defined in:
- app/view_models/guide/node_view.rb
Instance Attribute Summary collapse
-
#node_path ⇒ Object
readonly
Returns the value of attribute node_path.
Instance Method Summary collapse
- #current_locale ⇒ Object
-
#initialize(node:, bouncer:, diplomat:, node_path:) ⇒ NodeView
constructor
A new instance of NodeView.
- #locale_param ⇒ Object
- #multiple_formats? ⇒ Boolean
- #show_locale_switcher? ⇒ Boolean
- #supported_locales ⇒ Object
- #template_location ⇒ Object
- #user_is_privileged? ⇒ Boolean
- #uses_cells? ⇒ Boolean
- #visible_scenarios ⇒ Object
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_path ⇒ Object (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_locale ⇒ Object
52 53 54 |
# File 'app/view_models/guide/node_view.rb', line 52 def current_locale @diplomat.current_locale end |
#locale_param ⇒ Object
56 57 58 |
# File 'app/view_models/guide/node_view.rb', line 56 def locale_param 'temp_locale' end |
#multiple_formats? ⇒ 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
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_locales ⇒ Object
44 45 46 |
# File 'app/view_models/guide/node_view.rb', line 44 def supported_locales @diplomat.supported_locales end |
#template_location ⇒ Object
36 37 38 |
# File 'app/view_models/guide/node_view.rb', line 36 def template_location template || cell end |
#user_is_privileged? ⇒ 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
32 33 34 |
# File 'app/view_models/guide/node_view.rb', line 32 def uses_cells? cell.present? end |
#visible_scenarios ⇒ Object
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 |