lib/rack/app/extension.rb in rack-app-3.0.0.beta vs lib/rack/app/extension.rb in rack-app-3.0.0.delta

- old
+ new

@@ -1,29 +1,31 @@ -class Rack::App::Extension - class << self +module Rack::App::Extension - def includes - @includes ||= [] - end + extend self - def extends - @extends ||= [] - end + def apply_extensions(app_class, *extension_names) + extension_names.each do |extension_name| - def inheritances - @on_inheritances ||= [] - end + ext = find_extension_for(extension_name) || raise("Not registered extension name requested: #{extension_name}") + app_class.class_eval(&ext) - def include(endpoint_methods_module) - includes << endpoint_methods_module end + nil + end - def extend(app_class_methods_module) - extends << app_class_methods_module - end + def register(extension_name, &builder_block) + extension_registration_name = extension_name.to_s.to_sym + extensions[extension_registration_name]= builder_block + extension_registration_name + end - def on_inheritance(&block) - inheritances << block - end + protected + def extensions + @extensions ||= {} end + + def find_extension_for(sym_name) + return extensions[sym_name.to_s.to_sym] + end + end \ No newline at end of file