Class: JSONRPC::MethodConstraint Private
- Inherits:
-
Object
- Object
- JSONRPC::MethodConstraint
- Defined in:
- lib/jsonrpc/railtie/method_constraint.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This constraint allows Rails routes to be matched based on the JSON-RPC method name in the request, enabling method-specific routing.
Instance Method Summary collapse
-
#initialize(jsonrpc_method_name) ⇒ MethodConstraint
constructor
private
Initialize a new method constraint.
-
#matches?(request) ⇒ Boolean
private
Check if the request matches the configured method name.
Constructor Details
#initialize(jsonrpc_method_name) ⇒ MethodConstraint
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new method constraint
18 19 20 |
# File 'lib/jsonrpc/railtie/method_constraint.rb', line 18 def initialize(jsonrpc_method_name) @jsonrpc_method_name = jsonrpc_method_name.to_s end |
Instance Method Details
#matches?(request) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if the request matches the configured method name
27 28 29 30 31 32 33 |
# File 'lib/jsonrpc/railtie/method_constraint.rb', line 27 def matches?(request) jsonrpc_request = request.env['jsonrpc.request'] return false unless jsonrpc_request jsonrpc_request.method == @jsonrpc_method_name end |