Sha256: e91406ccd2d4b46a72f132563fa9f9fa01a4ebb62f9d42ed6d48a3dc065c9bcc

Contents?: true

Size: 1021 Bytes

Versions: 2

Compression:

Stored size: 1021 Bytes

Contents

module Chronicle
  module ETL
    # An authorization strategy for a third-party data source
    class Authorizer
      class << self
        attr_reader :provider_name

        # Macro for setting provider on an Authorizer
        def provider(provider_name)
          @provider_name = provider_name
        end

        # From all loaded Authorizers, return the first one that matches
        # a given provider
        #
        # @todo Have a proper identifier system for authorizers
        #   (to have more than one per plugin)
        def find_by_provider(provider)
          ObjectSpace.each_object(::Class).select {|klass| klass < self }.find do |authorizer|
            authorizer.provider_name == provider
          end
        end
      end

      # Construct a new authorizer
      def initialize(args)
      end

      # Main entry-point for authorization flows. Implemented by subclass
      def authorize!
        raise NotImplementedError
      end
    end
  end
end

require_relative 'oauth_authorizer'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chronicle-etl-0.5.5 lib/chronicle/etl/authorizer.rb
chronicle-etl-0.5.4 lib/chronicle/etl/authorizer.rb