Sha256: 7c99354d2e3c106d31102088dda388fa73fdda118e9effd2afcd09654934fdec

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

module BetterHelpers
  module Base

    def self.included base
      base.extend ClassMethods
    end

    module ClassMethods
      def self.extended base
        @@BetterHelpersMasterHelper ||= Class.new
      end

      def better_helpers namespace = nil, &block
        helper_class = Class.new(&block)
        helper_class.class_eval do
          include ActionView::Helpers
          include ActionView::Context
          extend ActionView::Helpers
          extend ActionView::Context
        end

        namespace ||= self.to_s.underscore
        names = namespace.to_s.split("/")
        name = names.shift

        hash = NamespaceToHash.new(helper_class, names).perform
        value = HashHierarchyToClass.new(hash, @@BetterHelpersMasterHelper).apply

        self.send(:define_method, name) { value }
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
better_helpers-0.1.2 lib/better_helpers/base.rb