Sha256: 7457d068581c8b122a9d97214df54a4e413c6c43604b9a497b6418c0bd56e3c9

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

module Smooth
  class Api
    module Tracking
      def apis
        @@apis ||= {}
      end

      def fetch_api name, &block
        existing = apis[name.to_sym]

        if existing.nil? && block_given?
          existing = apis[name.to_sym] = block.call(name.to_sym)
        end

        existing
      end

      def current_api
        apis[current_api_name] ||= Smooth::Api.default()
      end

      def current_api_name= value
        @@current_api_name = value
      end

      def current_api_name
        (@@current_api_name || :default).to_sym
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smooth-2.0.1 lib/smooth/api/tracking.rb