Sha256: 6f14d8248b27e9b3129423dbe3e060c3cc39547abe0c7b6d0f74ebf77d3abb7a

Contents?: true

Size: 477 Bytes

Versions: 7

Compression:

Stored size: 477 Bytes

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
alephant-publisher-0.6.10 lib/alephant/publisher/views.rb
alephant-publisher-0.6.9 lib/alephant/publisher/views.rb
alephant-publisher-0.6.8 lib/alephant/publisher/views.rb
alephant-publisher-0.6.7 lib/alephant/publisher/views.rb
alephant-publisher-0.6.6 lib/alephant/publisher/views.rb
alephant-publisher-0.6.5 lib/alephant/publisher/views.rb
alephant-publisher-0.6.4 lib/alephant/publisher/views.rb