Class: HttpRouter::Node::Arbitrary
- Inherits:
-
HttpRouter::Node
- Object
- HttpRouter::Node
- HttpRouter::Node::Arbitrary
- Defined in:
- lib/http_router/node/arbitrary.rb
Instance Attribute Summary (collapse)
-
- (Object) allow_partial
readonly
Returns the value of attribute allow_partial.
-
- (Object) blk
readonly
Returns the value of attribute blk.
-
- (Object) param_names
readonly
Returns the value of attribute param_names.
Attributes inherited from HttpRouter::Node
#node_position, #parent, #priority, #router
Instance Method Summary (collapse)
-
- (Arbitrary) initialize(router, parent, sallow_partial, blk, param_names)
constructor
A new instance of Arbitrary.
- - (Object) to_code
- - (Boolean) usable?(other)
Methods inherited from HttpRouter::Node
#add_arbitrary, #add_destination, #add_free_match, #add_glob, #add_glob_regexp, #add_lookup, #add_match, #add_request, #add_spanning_match, #add_variable
Constructor Details
- (Arbitrary) initialize(router, parent, sallow_partial, blk, param_names)
A new instance of Arbitrary
6 7 8 9 |
# File 'lib/http_router/node/arbitrary.rb', line 6 def initialize(router, parent, sallow_partial, blk, param_names) @allow_partial, @blk, @param_names = allow_partial, blk, param_names super(router, parent) end |
Instance Attribute Details
- (Object) allow_partial (readonly)
Returns the value of attribute allow_partial
4 5 6 |
# File 'lib/http_router/node/arbitrary.rb', line 4 def allow_partial @allow_partial end |
- (Object) blk (readonly)
Returns the value of attribute blk
4 5 6 |
# File 'lib/http_router/node/arbitrary.rb', line 4 def blk @blk end |
- (Object) param_names (readonly)
Returns the value of attribute param_names
4 5 6 |
# File 'lib/http_router/node/arbitrary.rb', line 4 def param_names @param_names end |
Instance Method Details
- (Object) to_code
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/http_router/node/arbitrary.rb', line 15 def to_code b, method_name = @blk, :blk_#{router.next_counter}" inject_root_methods { define_method(method_name) { b } } "#{"if request.path_finished?" unless @allow_partial} request.continue = proc { |state| if state #{super} end } #{method_name}[request, #{@param_names.nil? || @param_names.empty? ? '{}' : "Hash[#{@param_names.inspect}.zip(request.params)]"}] request.continue = nil #{"end" unless @allow_partial}" end |
- (Boolean) usable?(other)
11 12 13 |
# File 'lib/http_router/node/arbitrary.rb', line 11 def usable?(other) other.class == self.class && other.allow_partial == allow_partial && other.blk == blk && other.param_names == param_names end |