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-11.0.2 lib/rack/app/extension.rb
rack-app-11.0.1 lib/rack/app/extension.rb
rack-app-11.0.0 lib/rack/app/extension.rb
rack-app-10.0.0 lib/rack/app/extension.rb
rack-app-9.0.0 lib/rack/app/extension.rb
rack-app-8.1.0 lib/rack/app/extension.rb
rack-app-8.0.1 lib/rack/app/extension.rb
rack-app-8.0.0 lib/rack/app/extension.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-app-7.7.0/lib/rack/app/extension.rb
rack-app-7.7.0 lib/rack/app/extension.rb
rack-app-7.6.5 lib/rack/app/extension.rb
rack-app-7.6.4 lib/rack/app/extension.rb
rack-app-7.6.3 lib/rack/app/extension.rb
rack-app-7.6.2 lib/rack/app/extension.rb
rack-app-7.6.1 lib/rack/app/extension.rb
rack-app-7.6.0 lib/rack/app/extension.rb
rack-app-7.5.2 lib/rack/app/extension.rb
rack-app-7.5.1 lib/rack/app/extension.rb
rack-app-7.5.0 lib/rack/app/extension.rb
rack-app-7.4.0 lib/rack/app/extension.rb