Sha256: a7dea8432f07ce4ac2fe522aa8921bb4e0393dd1a03b61f20ff4c7acea42ada4

Contents?: true

Size: 464 Bytes

Versions: 2

Compression:

Stored size: 464 Bytes

Contents

require 'active_support/core_ext/string/inflections'

module Bbq
  module Core
    class Util
      def self.find_module(name, scope = nil)
        namespace = case scope
        when String, Symbol
          "::#{scope.to_s.camelize}"
        when Class
          "::#{scope.name}"
        when NilClass
          nil
        else
          "::#{scope.class.name}"
        end
        "#{namespace}::#{name.to_s.camelize}".constantize
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bbq-core-0.4.0 lib/bbq/core/util.rb
bbq-core-0.3.0 lib/bbq/core/util.rb