Sha256: a4e0301dfb350cc9017673e01cbc071e5d5a96c96278bb44416ba75137843138

Contents?: true

Size: 844 Bytes

Versions: 74

Compression:

Stored size: 844 Bytes

Contents

module Rack::App::Extension

  extend self

  def apply_extensions(app_class, applied_ext_names, apply_ext_names)
    apply_ext_names.each do |extension_name|
      extension_name = format_extension_name(extension_name)

      next if applied_ext_names.include?(extension_name)
      applied_ext_names << extension_name

      ext = find_extension_for(extension_name)
      app_class.class_eval(&ext)

    end
    nil
  end

  def format_extension_name(extension_name)
    extension_name.to_s.to_sym
  end

  def register(extension_name, &builder_block)
    extensions[format_extension_name(extension_name)]= builder_block
  end

  protected

  def extensions
    @extensions ||= {}
  end

  def find_extension_for(sym_name)
    return extensions[sym_name.to_s.to_sym] || raise("Not registered extension name requested: #{sym_name}")
  end

end

Version data entries

74 entries across 74 versions & 2 rubygems

Version Path
rack-app-6.1.0 lib/rack/app/extension.rb
rack-app-6.0.0 lib/rack/app/extension.rb
rack-app-5.12.0 lib/rack/app/extension.rb
rack-app-5.11.1 lib/rack/app/extension.rb
rack-app-5.11.0 lib/rack/app/extension.rb
rack-app-5.10.2 lib/rack/app/extension.rb
rack-app-5.10.1 lib/rack/app/extension.rb
rack-app-5.10.0 lib/rack/app/extension.rb
rack-app-5.9.0 lib/rack/app/extension.rb
rack-app-5.8.0 lib/rack/app/extension.rb
rack-app-5.7.0 lib/rack/app/extension.rb
rack-app-5.7.0.rc lib/rack/app/extension.rb
rack-app-5.6.0 lib/rack/app/extension.rb
rack-app-5.5.1 lib/rack/app/extension.rb
rack-app-5.4.0 lib/rack/app/extension.rb
rack-app-5.3.2 lib/rack/app/extension.rb
rack-app-5.3.1 lib/rack/app/extension.rb
rack-app-5.3.0 lib/rack/app/extension.rb
rack-app-5.2.0 lib/rack/app/extension.rb
rack-app-5.1.0 lib/rack/app/extension.rb