Sha256: 4ee3a204957ecc9acc2c540ed29845a6cd430efa31ab28abf928c082a5df2138

Contents?: true

Size: 515 Bytes

Versions: 11

Compression:

Stored size: 515 Bytes

Contents

module Objection
  module Inflector
    NAMESPACE_SEPARTOR = "/"

    def self.included(base)
      base.send :include, InstanceMethods
    end

    def self.constantize(string)
      scopes = string.split(NAMESPACE_SEPARTOR).map { |x| x.split("_") }.map { |x| x.map { |y| y.capitalize }.join("") }
      scopes.inject(Object) do |const, name|
        const.const_get name
      end
    end

    module InstanceMethods
      def objection_constantize
        Inflector.constantize(self)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
motion-objection-0.8.6 lib/motion-objection/inflector.rb
motion-objection-0.8.5 lib/motion-objection/inflector.rb
motion-objection-0.8.4 lib/motion-objection/inflector.rb
motion-objection-0.8.3 lib/motion-objection/inflector.rb
motion-objection-0.8.2 lib/motion-objection/inflector.rb
motion-objection-0.8.1 lib/motion-objection/inflector.rb
motion-objection-0.8 lib/motion-objection/inflector.rb
motion-objection-0.7.2 lib/motion-objection/inflector.rb
motion-objection-0.7.1 lib/motion-objection/inflector.rb
motion-objection-0.6.4 lib/motion-objection/inflector.rb
motion-objection-0.6.3 lib/motion-objection/inflector.rb