Sha256: fa3084108e24469dab63b1a1b175fa32c361db8eb830fa5b01109a77b37034eb

Contents?: true

Size: 868 Bytes

Versions: 6

Compression:

Stored size: 868 Bytes

Contents

require 'singleton'

module OpenStax
  module Accounts
    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::Accounts.configuration.enable_stubbing?
          instance.stubbed_paths[canonical_name] = block.call
        end
      end

      def self.get_path(canonical_name)
        OpenStax::Accounts.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

6 entries across 6 versions & 1 rubygems

Version Path
openstax_accounts-1.0.0 lib/openstax/accounts/route_helper.rb
openstax_accounts-0.3.0 lib/openstax/accounts/route_helper.rb
openstax_accounts-0.3 lib/openstax/accounts/route_helper.rb
openstax_accounts-0.2.1 lib/openstax/accounts/route_helper.rb
openstax_accounts-0.2.0 lib/openstax/accounts/route_helper.rb
openstax_accounts-0.1.0 lib/openstax/accounts/route_helper.rb