Module: ActionContext::InstanceMethods

Defined in:
lib/action_context.rb

Instance Method Summary collapse

Instance Method Details

#match_context(context, path) ⇒ Object

Checks the given path to see if it represents the specified context



19
20
21
22
23
24
# File 'lib/action_context.rb', line 19

def match_context(context, path)
  @contexts ||= {}
  return false unless @contexts[context].present?
  return true if path =~ @contexts[context]
  false
end

#set_context(context, matcher) ⇒ Object

Establish a connection between the current action and where we are in the current navigation context. Accepts a context symbol (e.g. :primary) and a Regex matcher (e.g. /^/users/).



13
14
15
16
# File 'lib/action_context.rb', line 13

def set_context(context, matcher)
  @contexts ||= {}
  @contexts[context] = matcher
end