lib/action_widget/extensions/middleman.rb in action_widget-0.7.0 vs lib/action_widget/extensions/middleman.rb in action_widget-0.8.0

- old
+ new

@@ -1,22 +1,27 @@ +require 'active_support/dependencies' + module ActionWidget - module Extensions - module Middleman - - class << self - - def register! - ::Middleman::Extensions.register(:action_widget, self) - end - - def registered(app) - app.send(:include, ::ActionWidget::ViewHelper) - end - alias included registered - + module Extensions + class Middleman < Middleman::Extension + def self.register + ::Middleman::Extensions.register(:action_widget, self) end - + + option :path + + def initialize(app, *) + super + options.path ||= File.join(app.root, 'lib') + raise ArgumentError, "Expected path to point to a directory" unless File.directory?(options.path) + end + + def after_configuration + ActiveSupport::Dependencies.autoload_paths |= [options.path] + ActiveSupport::Dependencies.clear + app.helpers(::ActionWidget::ViewHelper) + end end end end -ActionWidget::Extensions::Middleman.register! \ No newline at end of file +ActionWidget::Extensions::Middleman.register