File tree Expand file tree Collapse file tree 5 files changed +43
-25
lines changed Expand file tree Collapse file tree 5 files changed +43
-25
lines changed Original file line number Diff line number Diff line change 44# https://github.com/BetterErrors/better_errors/blob/v2.5.1/lib/better_errors/middleware.rb
55#
66
7- if defined? ( BetterErrors )
8- BetterErrors ::Middleware . class_eval do
9- prepend ( InertiaBetterErrors = Module . new do
10- def text? ( env )
11- return false if env [ "HTTP_X_INERTIA" ]
7+ module InertiaRails
8+ module InertiaBetterErrors
9+ def text? ( env )
10+ return false if env [ "HTTP_X_INERTIA" ]
1211
13- super
14- end
15- end )
12+ super
13+ end
1614 end
1715end
16+
17+ if defined? ( BetterErrors )
18+ BetterErrors ::Middleware . include InertiaRails ::InertiaBetterErrors
19+ end
Original file line number Diff line number Diff line change 44# https://github.com/rails/rails/blob/5-0-stable/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
55#
66
7- ActionDispatch :: DebugExceptions . class_eval do
8- prepend ( InertiaDebugExceptions = Module . new do
7+ module InertiaRails
8+ module InertiaDebugExceptions
99 def render_for_default_application ( request , wrapper )
1010 template = create_template ( request , wrapper )
1111 file = "rescues/#{ wrapper . rescue_template } "
@@ -19,5 +19,9 @@ def render_for_default_application(request, wrapper)
1919 end
2020 render ( wrapper . status_code , body , format )
2121 end
22- end )
22+ end
23+ end
24+
25+ if defined? ( ActionDispatch ::DebugExceptions )
26+ ActionDispatch ::DebugExceptions . prepend InertiaRails ::InertiaDebugExceptions
2327end
Original file line number Diff line number Diff line change 66# https://github.com/rails/rails/blob/6-0-stable/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
77#
88
9- ActionDispatch :: DebugExceptions . class_eval do
10- prepend ( InertiaDebugExceptions = Module . new do
9+ module InertiaRails
10+ module InertiaDebugExceptions
1111 def render_for_browser_request ( request , wrapper )
1212 template = create_template ( request , wrapper )
1313 file = "rescues/#{ wrapper . rescue_template } "
@@ -22,5 +22,9 @@ def render_for_browser_request(request, wrapper)
2222
2323 render ( wrapper . status_code , body , format )
2424 end
25- end )
25+ end
26+ end
27+
28+ if defined? ( ActionDispatch ::DebugExceptions )
29+ ActionDispatch ::DebugExceptions . prepend InertiaRails ::InertiaDebugExceptions
2630end
Original file line number Diff line number Diff line change 1- ActionDispatch ::Routing ::Mapper . class_eval do
2- def inertia ( args , &block )
3- route = args . keys . first
4- component = args . values . first
1+ module InertiaRails
2+ module InertiaMapper
3+ def inertia ( args , &block )
4+ route = args . keys . first
5+ component = args . values . first
56
6- get ( route => 'inertia_rails/static#static' , defaults : { component : component } )
7+ get ( route => 'inertia_rails/static#static' , defaults : { component : component } )
8+ end
79 end
810end
11+
12+ ActionDispatch ::Routing ::Mapper . include InertiaRails ::InertiaMapper
Original file line number Diff line number Diff line change 1- ActionDispatch ::Request . class_eval do
2- def inertia?
3- key? 'HTTP_X_INERTIA'
4- end
1+ module InertiaRails
2+ module InertiaRequest
3+ def inertia?
4+ key? 'HTTP_X_INERTIA'
5+ end
56
6- def inertia_partial?
7- key? ( 'HTTP_X_INERTIA_PARTIAL_COMPONENT' )
7+ def inertia_partial?
8+ key? ( 'HTTP_X_INERTIA_PARTIAL_COMPONENT' )
9+ end
810 end
911end
12+
13+ ActionDispatch ::Request . include InertiaRails ::InertiaRequest
You can’t perform that action at this time.
0 commit comments