Class: ViewModel::TraversalContext::SharedContext

Inherits:
Object
  • Object
show all
Defined in:
lib/view_model/traversal_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_control: ViewModel::AccessControl::Open.new, callbacks: []) ⇒ SharedContext

Returns a new instance of SharedContext.



10
11
12
13
14
15
16
# File 'lib/view_model/traversal_context.rb', line 10

def initialize(access_control: ViewModel::AccessControl::Open.new, callbacks: [])
  @access_control = access_control
  # Access control is guaranteed to be run after callbacks that may have
  # side-effects on the view.
  pre_callbacks, post_callbacks = callbacks.partition { |c| c.class.updates_view? }
  @callbacks = pre_callbacks + [access_control] + post_callbacks
end

Instance Attribute Details

#access_controlObject (readonly)

Returns the value of attribute access_control.



8
9
10
# File 'lib/view_model/traversal_context.rb', line 8

def access_control
  @access_control
end

#callbacksObject (readonly)

Returns the value of attribute callbacks.



8
9
10
# File 'lib/view_model/traversal_context.rb', line 8

def callbacks
  @callbacks
end