Class: JSRailsRoutes::RouteSet
- Inherits:
-
Object
- Object
- JSRailsRoutes::RouteSet
- Includes:
- Enumerable
- Defined in:
- lib/js_rails_routes/route_set.rb
Overview
Encapsulate a set of routes
Instance Attribute Summary collapse
- #name ⇒ String readonly
- #route_set ⇒ ActionDispatch::Routing::RouteSet readonly
- #routes ⇒ Array<JSRailsRoutes::Route> readonly
Class Method Summary collapse
Instance Method Summary collapse
- #each {|JSRailsRoutes::Route| ... } ⇒ Object
-
#initialize(name, routes) ⇒ RouteSet
constructor
A new instance of RouteSet.
- #match? ⇒ Boolean
Constructor Details
#initialize(name, routes) ⇒ RouteSet
Returns a new instance of RouteSet.
36 37 38 39 40 41 42 43 |
# File 'lib/js_rails_routes/route_set.rb', line 36 def initialize(name, routes) @name = name @route_set = route_set @routes = routes.routes .select(&:name) .map { |route| Route.new(route) } .select(&:match?) end |
Instance Attribute Details
#name ⇒ String (readonly)
26 27 28 |
# File 'lib/js_rails_routes/route_set.rb', line 26 def name @name end |
#route_set ⇒ ActionDispatch::Routing::RouteSet (readonly)
29 30 31 |
# File 'lib/js_rails_routes/route_set.rb', line 29 def route_set @route_set end |
#routes ⇒ Array<JSRailsRoutes::Route> (readonly)
32 33 34 |
# File 'lib/js_rails_routes/route_set.rb', line 32 def routes @routes end |
Class Method Details
.correct_matching_route_set_list ⇒ Array<JSRailsRoutes::RouteSet>
11 12 13 14 15 16 17 18 |
# File 'lib/js_rails_routes/route_set.rb', line 11 def self.correct_matching_route_set_list [ RouteSet.new('Rails', ::Rails.application.routes), ::Rails::Engine.subclasses.map do |engine| RouteSet.new(engine.name, engine.routes) end ].flatten.select(&:match?) end |
Instance Method Details
#each {|JSRailsRoutes::Route| ... } ⇒ Object
Note:
Implementation for Enumerable
23 |
# File 'lib/js_rails_routes/route_set.rb', line 23 delegate :each, to: :routes |
#match? ⇒ Boolean
46 47 48 |
# File 'lib/js_rails_routes/route_set.rb', line 46 def match? name !~ config.exclude_engines && routes.present? && config.route_set_filter.call(self) end |