Sha256: 5b22c0e58cc8153ac56ea07c5d1e86ad4a9a3b473790d34843638a41e9ca16e1

Contents?: true

Size: 865 Bytes

Versions: 11

Compression:

Stored size: 865 Bytes

Contents

require 'singleton'

module OpenStax
  module Connect
    class RouteHelper
      
      include Singleton

      # Registers a path against a canonical name.  An optional
      # block can be provided to give the stubbed path
      def self.register_path(canonical_name, path, &block)
        instance.paths[canonical_name] = path
        if block.present? && OpenStax::Connect.configuration.enable_stubbing?
          instance.stubbed_paths[canonical_name] = block.call
        end
      end

      def self.get_path(canonical_name)
        OpenStax::Connect.configuration.enable_stubbing? ?
          instance.stubbed_paths[canonical_name] :
          instance.paths[canonical_name]
      end

      def initialize
        self.paths = {}
        self.stubbed_paths = {}
      end

      attr_accessor :paths
      attr_accessor :stubbed_paths

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
openstax_connect-0.1.0 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.10 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.9 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.8 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.7 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.6 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.5 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.4 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.3 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.2 lib/openstax/connect/route_helper.rb
openstax_connect-0.0.1 lib/openstax/connect/route_helper.rb