Sha256: 02890223175e4a2d8be6d4f3002d0608916a08fea776329b29790265e0765e02

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true
class Rack::App::Router::Tree::Leaf < ::Hash
  require 'rack/app/router/tree/leaf/vein'

  def get(env)
    vein = vein_by(env)
    vein && vein.get(env)
  end

  def set(endpoint)
    endpoint.request_methods.each do |request_method|
      vein_for(request_method).set(endpoint)
    end
  end

  def struct
    hash = {}
    self.each do |request_method, vein|
      hash[request_method] = vein.struct
    end
    hash
  end

  protected

  def vein_by(env)
    self[env[Rack::App::Constants::ENV::REQUEST_METHOD].to_sym]
  end

  def vein_for(request_method)
    self[request_method] ||= Rack::App::Router::Tree::Leaf::Vein.new
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-app-5.11.0 lib/rack/app/router/tree/leaf.rb