Class: Landline::Path
Overview
Primary building block of request navigation.
Direct Known Subclasses
Constant Summary collapse
- ProcContext =
Landline::ProcessorContext
- Context =
Landline::PathContext
Instance Attribute Summary collapse
-
#bounce ⇒ Object
Returns the value of attribute bounce.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#pipeline ⇒ Object
Returns the value of attribute pipeline.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Attributes inherited from Node
Instance Method Summary collapse
-
#filter(&block) {|request| ... } ⇒ Object
Add a filter to the path.
-
#initialize(path, parent:, **params, &setup) ⇒ Path
constructor
A new instance of Path.
-
#postprocess(&block) {|request, response| ... } ⇒ Object
Add a postprocessor to the path.
-
#preprocess(&block) {|request| ... } ⇒ Object
Add a preprocessor to the path.
-
#process(request) ⇒ Boolean
Method callback on successful request navigation.
Methods inherited from Node
Constructor Details
#initialize(path, parent:, **params, &setup) ⇒ Path
Returns a new instance of Path.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/landline/path.rb', line 42 def initialize(path, parent:, **params, &setup) super(path, parent: parent, **params) # Child nodes array @children = [] # Arrays of preprocessors, postprocessors and filters @preprocessors = [] @postprocessors = [] @filters = [] # Contexts setup context = self.class::Context.new(self) context.instance_exec(&setup) @proccontext = self.class::ProcContext.new(self) end |
Instance Attribute Details
#bounce ⇒ Object
Returns the value of attribute bounce.
94 95 96 |
# File 'lib/landline/path.rb', line 94 def bounce @bounce end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
92 93 94 |
# File 'lib/landline/path.rb', line 92 def children @children end |
#pipeline ⇒ Object
Returns the value of attribute pipeline.
94 95 96 |
# File 'lib/landline/path.rb', line 94 def pipeline @pipeline end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
92 93 94 |
# File 'lib/landline/path.rb', line 92 def properties @properties end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
92 93 94 |
# File 'lib/landline/path.rb', line 92 def request @request end |
Instance Method Details
#filter(&block) {|request| ... } ⇒ Object
Add a filter to the path. Blocks path access if a filter returns false.
88 89 90 |
# File 'lib/landline/path.rb', line 88 def filter(&block) @filters.append(block) end |
#postprocess(&block) {|request, response| ... } ⇒ Object
Add a postprocessor to the path.
80 81 82 |
# File 'lib/landline/path.rb', line 80 def postprocess(&block) @postprocessors.append(block) end |
#preprocess(&block) {|request| ... } ⇒ Object
Add a preprocessor to the path. Does not modify path execution.
72 73 74 |
# File 'lib/landline/path.rb', line 72 def preprocess(&block) @preprocessors.append(block) end |
#process(request) ⇒ Boolean
Method callback on successful request navigation. Finds the next appropriate path to go to.
60 61 62 63 64 65 66 |
# File 'lib/landline/path.rb', line 60 def process(request) if @pipeline @pipeline.call(request) { |inner_req| process_wrapped(inner_req) } else process_wrapped(request) end end |