Class: VcShortcut::ChainContext

Inherits:
Object
  • Object
show all
Defined in:
lib/vc_shortcut/chain_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ ChainContext

Returns a new instance of ChainContext.



17
18
19
20
21
22
23
24
# File 'lib/vc_shortcut/chain_context.rb', line 17

def initialize(view_context)
  @view_context = view_context
  @chain = []
  @component = nil
  @call_args = []
  @call_kwargs = {}
  @call_block = nil
end

Instance Attribute Details

#call_argsObject

Arguments for the leaf component



15
16
17
# File 'lib/vc_shortcut/chain_context.rb', line 15

def call_args
  @call_args
end

#call_blockObject

Arguments for the leaf component



15
16
17
# File 'lib/vc_shortcut/chain_context.rb', line 15

def call_block
  @call_block
end

#call_kwargsObject

Arguments for the leaf component



15
16
17
# File 'lib/vc_shortcut/chain_context.rb', line 15

def call_kwargs
  @call_kwargs
end

#chainObject (readonly)

Chain until now. E.g if you call vc.admin.button When processing :admin, chain will be [:admin] Then, when processing :button, chain will be [:admin, :button]



9
10
11
# File 'lib/vc_shortcut/chain_context.rb', line 9

def chain
  @chain
end

#componentObject

The leaf component found by the ‘find` proc when registering a shortcut



12
13
14
# File 'lib/vc_shortcut/chain_context.rb', line 12

def component
  @component
end

#view_contextObject (readonly)

The view_context (e.g an ActionView::Base or a ViewComponent instance)



4
5
6
# File 'lib/vc_shortcut/chain_context.rb', line 4

def view_context
  @view_context
end

Instance Method Details

#chain_camelized(rindex = -1)) ⇒ Object



26
27
28
# File 'lib/vc_shortcut/chain_context.rb', line 26

def chain_camelized(rindex = -1)
  @chain[0..rindex].join('/').camelize
end