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
870 871 872 873 874 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 870 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
882 883 884 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 882 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.
897 898 899 900 901 902 903 904 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 897 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
876 877 878 879 880 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 876 def self.reset_configuration @noop_proc_class = nil @strategy_serve_class = nil @strategy_call_class = nil end |
.strategy_call_class ⇒ Object
890 891 892 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 890 def self.strategy_call_class @strategy_call_class || RactorRailsShim.singleton_class.const_get(:StrategyCall) end |
.strategy_serve_class ⇒ Object
886 887 888 |
# File 'lib/ractor_rails_shim/patches/action_dispatch.rb', line 886 def self.strategy_serve_class @strategy_serve_class || RactorRailsShim.singleton_class.const_get(:StrategyServe) end |