Sha256: d76d038f523cea95871fff1bb9d49b174d69bd16cdd96240a17c64b72bf121f9

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 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 BetterHelpers::Railties::RequestContext
        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.3 lib/better_helpers/base.rb