Class: Navigatrix::Item::State
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Navigatrix::Item::State
- Extended by:
- Forwardable
- Defined in:
- lib/navigatrix/item.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #action_matches? ⇒ Boolean
- #actions ⇒ Object
- #applicable? ⇒ Boolean
- #controller_matches? ⇒ Boolean
-
#initialize(config, context) ⇒ State
constructor
A new instance of State.
- #match?(pattern, target) ⇒ Boolean
- #path_matches? ⇒ Boolean
Constructor Details
#initialize(config, context) ⇒ State
Returns a new instance of State.
79 80 81 82 |
# File 'lib/navigatrix/item.rb', line 79 def initialize(config, context) @context = context super(config) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
77 78 79 |
# File 'lib/navigatrix/item.rb', line 77 def context @context end |
Instance Method Details
#action_matches? ⇒ Boolean
92 93 94 |
# File 'lib/navigatrix/item.rb', line 92 def action_matches? actions.empty? || actions.include?(action_name) end |
#actions ⇒ Object
104 105 106 |
# File 'lib/navigatrix/item.rb', line 104 def actions Array.wrap(super) end |
#applicable? ⇒ Boolean
84 85 86 |
# File 'lib/navigatrix/item.rb', line 84 def applicable? path ? path_matches? : (controller_matches? && action_matches?) end |
#controller_matches? ⇒ Boolean
88 89 90 |
# File 'lib/navigatrix/item.rb', line 88 def controller_matches? match?(controller, controller_name) end |
#match?(pattern, target) ⇒ Boolean
100 101 102 |
# File 'lib/navigatrix/item.rb', line 100 def match?(pattern, target) pattern.is_a?(Regexp) ? target[pattern] : pattern == target end |
#path_matches? ⇒ Boolean
96 97 98 |
# File 'lib/navigatrix/item.rb', line 96 def path_matches? match?(path, current_path) end |