Class: Takagi::Router::MetadataExtractor::MetadataExtractionContext
- Inherits:
-
Object
- Object
- Takagi::Router::MetadataExtractor::MetadataExtractionContext
- Extended by:
- Forwardable
- Includes:
- Helpers
- Defined in:
- lib/takagi/router/metadata_extractor.rb
Overview
Special context for boot-time metadata extraction Uses entry’s AttributeSet directly (safe because boot-time is single-threaded)
Note: This class inherits from Takagi::Router::RouteContext, but since this file is loaded before RouteContext is defined, we define it as a placeholder here and will reopen it after Router is loaded.
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(entry, request, params, receiver) ⇒ MetadataExtractionContext
constructor
A new instance of MetadataExtractionContext.
- #run(block) ⇒ Object
Methods included from Helpers
#halt, #json, #respond, #validate_params
Constructor Details
#initialize(entry, request, params, receiver) ⇒ MetadataExtractionContext
Returns a new instance of MetadataExtractionContext.
68 69 70 71 72 73 74 75 76 |
# File 'lib/takagi/router/metadata_extractor.rb', line 68 def initialize(entry, request, params, receiver) @entry = entry @request = request @params = params @receiver = receiver # Use entry's AttributeSet directly for boot-time extraction # This is safe because metadata extraction runs once at boot time (single-threaded) @core_attributes = @entry.attribute_set end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object (private)
Delegates method calls to the receiver (application instance)
102 103 104 105 106 107 108 |
# File 'lib/takagi/router/metadata_extractor.rb', line 102 def method_missing(name, ...) if @receiver.respond_to?(name) @receiver.public_send(name, ...) else super end end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
62 63 64 |
# File 'lib/takagi/router/metadata_extractor.rb', line 62 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
62 63 64 |
# File 'lib/takagi/router/metadata_extractor.rb', line 62 def request @request end |
Instance Method Details
#run(block) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/takagi/router/metadata_extractor.rb', line 78 def run(block) return unless block args = case block.arity when 0 then [] when 1 then [request] else [request, params] end args = [request, params] if block.arity.negative? # Support halt for early returns result = catch(:halt) do instance_exec(*args, &block) end result ensure @core_attributes.apply! end |