Class: JSRailsRoutes::Route
- Inherits:
-
Object
- Object
- JSRailsRoutes::Route
- Defined in:
- lib/js_rails_routes/route.rb
Overview
Encapsulate a single routing rule
Instance Attribute Summary collapse
-
#name ⇒ String
Route name.
- #path ⇒ String readonly
- #route ⇒ ActionDispatch::Journey::Route readonly
Instance Method Summary collapse
-
#initialize(route) ⇒ Route
constructor
A new instance of Route.
- #match? ⇒ Boolean
Constructor Details
#initialize(route) ⇒ Route
Returns a new instance of Route.
16 17 18 19 20 |
# File 'lib/js_rails_routes/route.rb', line 16 def initialize(route) @route = route @name = route.name @path = route.path.spec.to_s.split('(').first end |
Instance Attribute Details
#name ⇒ String
Returns route name. It becomes JavaScript function name.
7 8 9 |
# File 'lib/js_rails_routes/route.rb', line 7 def name @name end |
#path ⇒ String (readonly)
10 11 12 |
# File 'lib/js_rails_routes/route.rb', line 10 def path @path end |
#route ⇒ ActionDispatch::Journey::Route (readonly)
13 14 15 |
# File 'lib/js_rails_routes/route.rb', line 13 def route @route end |
Instance Method Details
#match? ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'lib/js_rails_routes/route.rb', line 23 def match? # rubocop:disable Metrics/AbcSize return false if config.include_paths !~ path return false if config.exclude_paths =~ path return false if config.include_names !~ name return false if config.exclude_names =~ name config.route_filter.call(self) end |