Sha256: 88a1482af1b076deebfc544ad303e8b351b2fb9d6ee2cbb391b65d434e330b14

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

module Apitizer
  module Routing
    class Path
      attr_reader :steps, :node

      def initialize(steps: [], node: nil)
        @steps = steps
        @node = node
      end

      def address
        @steps.map(&:to_s).join('/')
      end

      def advance(step, node:, on: nil)
        @steps << step
        @node = node
        @on = on
      end

      def permit?(action)
        @node && @node.permit?(action, on: @on)
      end

      def on?(on)
        @on == on
      end

      def clone
        self.class.new(steps: @steps.clone, node: @node)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apitizer-0.0.2 lib/apitizer/routing/path.rb