Sha256: 126109a6adba83f002b6c34b1518905838b4952f25641f9f3d4e40ed2674d457

Contents?: true

Size: 570 Bytes

Versions: 54

Compression:

Stored size: 570 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.formats.merge!(formats)

    [:middlewares, :before, :after].each do |type|
      child.__send__(type).push(*__send__(type))
    end

    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

54 entries across 54 versions & 2 rubygems

Version Path
rack-app-6.1.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-6.0.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.12.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.11.1 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.11.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.10.2 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.10.1 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.10.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.9.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.8.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.7.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.7.0.rc lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.6.0 lib/rack/app/singleton_methods/inheritance.rb
rack-app-5.5.1 lib/rack/app/singleton_methods/inheritance.rb