class JSRailsRoutes::Route

Encapsulate a single routing rule

Attributes

name[RW]

@return [String] route name. It becomes JavaScript function name.

path[R]

@return [String]

route[R]

@return [ActionDispatch::Journey::Route]

Public Class Methods

new(route) click to toggle source

@param route [ActionDispatch::Journey::Route]

# 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

Public Instance Methods

match?() click to toggle source

@return [Boolean]

# 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

Private Instance Methods

config() click to toggle source

@return [JSRailsRoutes::Configuration]

# File lib/js_rails_routes/route.rb, line 35
def config
  JSRailsRoutes.config
end