Sha256: 54acadbb58dcf15dc6df3a4d8d0ab1c63979241a08e5539c76c71a354bbf8a4d

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

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

      def initialize(options = {})
        @steps = options[:steps] || []
        @node = options[:node]
      end

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

      def advance(step, options)
        @steps << step
        @node = options.fetch(:node)
        @on = options[: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.3 lib/apitizer/routing/path.rb