Sha256: 80782ec810f307313a995c5432da3cee61e903e9e0861fa9b3e05302924bead3

Contents?: true

Size: 996 Bytes

Versions: 2

Compression:

Stored size: 996 Bytes

Contents

module Arrest

  class Source 
    class << self
      attr_reader :source
      attr_reader :mod
      attr_reader :header_decorator

      def source=(host=nil)
        if host == nil || host.blank?
          @source = MemSource.new
        else
          @source = HttpSource.new host 
        end
        @source
      end

      def mod=(mod=nil)
        if mod == nil
          @mod = Kernel
        elsif mod.is_a?(Module)
          @mod = mod
        else
          raise "Expected module but got #{mod.class.name}"
        end
      end

      def header_decorator=(hd=nil)
        puts "Setting headerd to #{hd}"
        if hd == nil
          @header_decorator = self
        elsif hd.respond_to?(:headers)
          @header_decorator = hd
        else
          raise "Header_decorator must be an object that returns an hash for the method headers"
        end
      end

      def headers
        {}
      end

    end
  end
  Source.mod = nil
  Source.header_decorator = Source
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arrest-0.0.4 lib/arrest/source.rb
arrest-0.0.3 lib/arrest/source.rb