Sha256: ed804e4e2898fde8215fff1a1e36cf599f2aa058acc7e0641da6751e64a73559

Contents?: true

Size: 796 Bytes

Versions: 5

Compression:

Stored size: 796 Bytes

Contents

module Rack::App::SingletonMethods::Utility

  def serializer(&definition_how_to_serialize)
    @serializer ||= Rack::App::Serializer.new

    unless definition_how_to_serialize.nil?
      @serializer.set_serialization_logic(definition_how_to_serialize)
    end

    return @serializer
  end

  def headers(new_headers=nil)
    @headers ||= {}
    @headers.merge!(new_headers) if new_headers.is_a?(Hash)
    @headers
  end

  def middlewares(&block)
    @middlewares ||= []
    @middlewares << block unless block.nil?
    @middlewares
  end

  alias middleware middlewares

  def error(*exception_classes, &block)
    @error_handler ||= Rack::App::ErrorHandler.new
    unless block.nil?
      @error_handler.register_handler(exception_classes, block)
    end

    return @error_handler
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rack-app-2.3.1 lib/rack/app/singleton_methods/utility.rb
rack-app-2.3.0 lib/rack/app/singleton_methods/utility.rb
rack-app-2.2.0 lib/rack/app/singleton_methods/utility.rb
rack-app-2.1.0 lib/rack/app/singleton_methods/utility.rb
rack-app-2.0.0 lib/rack/app/singleton_methods/utility.rb