Module: RactorRailsShim::ActionDispatchStrategy
- Defined in:
- lib/ractor_rails_shim/patches/action_dispatch.rb
Overview
RactorRailsShim::ActionDispatchStrategy — the role object that
identifies which ActionDispatch strategy a Proc is and returns its
shareable replacement (extracted from the facade god module in
Step 22.5, Issue #22; POODR §1 SRP).
The Proc stored in
ActionDispatch::Routing::Mapper::Constraints#@strategy is the
constant SERVE or CALL (assigned by reference), so equal? is
the robust identifier — independent of the source line number,
which any Rails patch release can shift. Returns NoOpProc for an
unknown Proc (defensive; never mis-route).
The facade method _strategy_replacement_for delegates to
.replacement_for until Issue #31 removes it. NoOpProc,
StrategyServe, StrategyCall (defined above on the singleton class)
are collaborators reached through the facade; Issue #23 will inject
them as constructor arguments.
Class Method Summary collapse
- .configure(noop_proc_class: nil, strategy_serve_class: nil, strategy_call_class: nil) ⇒ Object
- .noop_proc_class ⇒ Object
-
.replacement_for(proc_obj) ⇒ Object
Return the shareable replacement for the given strategy Proc.
- .reset_configuration ⇒ Object
- .strategy_call_class ⇒ Object
- .strategy_serve_class ⇒ Object
Class Method Details
.configure(noop_proc_class: nil, strategy_serve_class: nil, strategy_call_class: nil) ⇒ Object
979 980 981 982 983 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 979 def self.configure(noop_proc_class: nil, strategy_serve_class: nil, strategy_call_class: nil) @noop_proc_class = noop_proc_class @strategy_serve_class = strategy_serve_class @strategy_call_class = strategy_call_class end |
.noop_proc_class ⇒ Object
991 992 993 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 991 def self.noop_proc_class @noop_proc_class || RactorRailsShim.singleton_class.const_get(:NoOpProc) end |
.replacement_for(proc_obj) ⇒ Object
Return the shareable replacement for the given strategy Proc. SERVE -> strategy_serve_class, CALL -> strategy_call_class, unknown -> noop_proc_class.
1006 1007 1008 1009 1010 1011 1012 1013 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 1006 def self.replacement_for(proc_obj) constraints = defined?(::ActionDispatch::Routing::Mapper::Constraints) ? ::ActionDispatch::Routing::Mapper::Constraints : nil return noop_proc_class.new unless constraints return strategy_serve_class.new if proc_obj.equal?(constraints::SERVE) return strategy_call_class.new if proc_obj.equal?(constraints::CALL) noop_proc_class.new end |
.reset_configuration ⇒ Object
985 986 987 988 989 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 985 def self.reset_configuration @noop_proc_class = nil @strategy_serve_class = nil @strategy_call_class = nil end |
.strategy_call_class ⇒ Object
999 1000 1001 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 999 def self.strategy_call_class @strategy_call_class || RactorRailsShim.singleton_class.const_get(:StrategyCall) end |
.strategy_serve_class ⇒ Object
995 996 997 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 995 def self.strategy_serve_class @strategy_serve_class || RactorRailsShim.singleton_class.const_get(:StrategyServe) end |