Sha256: 54e3af260e3a393122a1451576f1ffd0a60be02647a164e7ca5ac8bb965fede9
Contents?: true
Size: 900 Bytes
Versions: 15
Compression:
Stored size: 900 Bytes
Contents
module Jets::Router class EngineMount def self.find_by(request_path: nil, engine: nil) new.find_by(request_path: request_path, engine: engine) end def find_by(request_path: nil, engine: nil) mount = if request_path find_by_request_path(request_path) elsif engine find_by_engine(engine) end return unless mount OpenStruct.new(at: mount[0], engine: mount[1]) end def find_by_request_path(request_path) mounted_engines.find do |at, engine| request_path.starts_with?(at) end end def find_by_engine(engine) mounted = mounted_engines.find do |at, mounted_engine| mounted_engine == engine end end # Example mounted_engines: {"/blog"=>Blorgh::Engine} def mounted_engines Jets::Router::Dsl::Mount.mounted_engines end end end
Version data entries
15 entries across 15 versions & 1 rubygems