Sha256: 442c149da001f9760ba5bcbbc8b3b686b3fdec344b5df4e3dd47733e0dc52a73

Contents?: true

Size: 552 Bytes

Versions: 3

Compression:

Stored size: 552 Bytes

Contents

module Rack::App::SingletonMethods::Inheritance

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

  protected

  def inherited(child)

    child.serializer(&serializer.logic)
    child.headers.merge!(headers)
    child.__send__(:middlewares).push(*middlewares)

    on_inheritance.each do |block|
      block.call(self, child)
      child.on_inheritance(&block)
    end

    error.handlers.each do |ex_class, block|
      child.error(ex_class, &block)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-app-3.0.0.gamma lib/rack/app/singleton_methods/inheritance.rb
rack-app-3.0.0.beta lib/rack/app/singleton_methods/inheritance.rb
rack-app-3.0.0.alpha lib/rack/app/singleton_methods/inheritance.rb