Sha256: 2644e0f83ae0480e24a2fe34f0fab7cd774aa89762d8c94610efde747ae6cd39

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'active_support'
require 'active_support/core_ext'
require 'acfs/version'

module Acfs
  extend ActiveSupport::Autoload

  autoload :Collection
  autoload :Model
  autoload :Request
  autoload :Response
  autoload :Service

  module Middleware
    extend ActiveSupport::Autoload

    autoload :Base
    autoload :Print
    autoload :JsonDecoder
  end

  module Adapter
    extend ActiveSupport::Autoload

    autoload :Typhoeus
  end

  class << self

    # Run all queued
    def run
      adapter.run
    end

    def queue(req, &block)
      request = middleware.call Request.new(req)
      request.on_complete &block if block_given?
      adapter.queue request
    end

    def adapter
      @adapter ||= Adapter::Typhoeus.new
    end

    def middleware
      @middleware ||= lambda { |request| request }
    end

    def use(klass, options = {})
      @middlewares ||= []

      return false if @middlewares.include? klass

      @middlewares << klass
      @middleware = klass.new(middleware, options)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acfs-0.5.1 lib/acfs.rb
acfs-0.5.0 lib/acfs.rb
acfs-0.4.0 lib/acfs.rb
acfs-0.3.0 lib/acfs.rb