Sha256: 9fe79620a6c21521f5dff1981f09007f0cc19dd38969b34d260568c2aa773ada

Contents?: true

Size: 558 Bytes

Versions: 3

Compression:

Stored size: 558 Bytes

Contents

require 'alephant/publisher/views/html'
require 'alephant/publisher/views/json'

module Alephant
  module Publisher
    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

3 entries across 3 versions & 1 rubygems

Version Path
alephant-publisher-0.6.3 lib/alephant/publisher/views.rb
alephant-publisher-0.6.2 lib/alephant/publisher/views.rb
alephant-publisher-0.6.1 lib/alephant/publisher/views.rb