Sha256: 6dec0aab5b9bb7d7829759ff7220fb854f789677290418bb4af9a95fdb9cac89

Contents?: true

Size: 1.59 KB

Versions: 67

Compression:

Stored size: 1.59 KB

Contents

require "arrest/handler"
module Arrest
  def self.debug s
    if Arrest::Source.debug
      puts s
    end
  end

  class Source
    class << self
      attr_accessor :debug
      attr_reader :source
      attr_reader :mod
      attr_reader :header_decorator
      attr_accessor :json_key_converter
      attr_accessor :skip_validations
      attr_accessor :error_handler
      attr_accessor :call_logger

      def source=(host=nil)
        if [nil, ""].include?(host)
          @source = MemSource.new
          Arrest::logger.info "Setting Arrest host empty in-memory-store"
        else
          @source = HttpSource.new host
          Arrest::logger.info "Setting Arrest host to #{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)
        Arrest::debug "Setting headerd to #{hd}"
        if hd == nil
          @header_decorator = Handlers::Header_decorator
        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
    end
  end
  Source.mod = nil
  Source.header_decorator = Handlers::HeaderDecorator
  Source.debug = false
  Source.json_key_converter = Handlers::IdentityJSONKeyConverter
  Source.error_handler = Handlers::ErrorHandler
  Source.call_logger = Handlers::CallLogger
  Source.skip_validations = false

end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
arrest-0.0.70 lib/arrest/source.rb
arrest-0.0.69 lib/arrest/source.rb
arrest-0.0.68 lib/arrest/source.rb
arrest-0.0.67 lib/arrest/source.rb
arrest-0.0.66 lib/arrest/source.rb
arrest-0.0.65 lib/arrest/source.rb
arrest-0.0.64 lib/arrest/source.rb
arrest-0.0.63 lib/arrest/source.rb
arrest-0.0.62 lib/arrest/source.rb
arrest-0.0.61 lib/arrest/source.rb
arrest-0.0.60 lib/arrest/source.rb
arrest-0.0.59 lib/arrest/source.rb
arrest-0.0.58 lib/arrest/source.rb
arrest-0.0.57 lib/arrest/source.rb
arrest-0.0.56 lib/arrest/source.rb
arrest-0.0.54 lib/arrest/source.rb
arrest-0.0.53 lib/arrest/source.rb
arrest-0.0.52 lib/arrest/source.rb
arrest-0.0.51 lib/arrest/source.rb
arrest-0.0.50 lib/arrest/source.rb