Sha256: c7929905b49559a77d2d977be5940c8c0393c3c75c69ce882b661718bde7e7c2

Contents?: true

Size: 476 Bytes

Versions: 1

Compression:

Stored size: 476 Bytes

Contents

module Alephant
  module Renderer
    module Views
      @@views = {}

      def self.register(klass)
        @@views[underscorify(klass.name.split("::").last)] = klass
      end

      def self.get_registered_class(id)
        @@views[id]
      end

      def self.underscorify(str)
        str.gsub(/::/, "/").
          gsub(/([A-Z]+)([A-Z][a-z])/,"\1_\2").
          gsub(/([a-z\d])([A-Z])/,"\1_\2").
          tr("-", "_").
          downcase
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-renderer-2.0.2 lib/alephant/renderer/views.rb