Sha256: 8be6066b8c0392c60bd275550ef151aa3b7348a67e15ca55e3c27f9574a51b35

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

module ActionWidget
  module ViewHelper

    def method_missing(name, *args, &block)
      return super unless name =~ /_widget$/

      klass = begin
        "#{name.to_s.camelcase}".constantize
      rescue NameError, LoadError
        return super
      end

      ActionWidget::ViewHelper.module_eval <<-RUBY
        def #{name}(*args, &block)                  # def example_widget(*args, &block)
          #{klass}.new(self, *args).render(&block)  #   ExampleWidget.new(self, *args).render(&block)
        end                                         # end
      RUBY

      send(name, *args, &block)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
action_widget-0.5.1 lib/action_widget/view_helper.rb