Sha256: aa703fd6815fd05c0b63273750cb0e0742fbdc7acc828c44081d9805f3f14cee

Contents?: true

Size: 461 Bytes

Versions: 6

Compression:

Stored size: 461 Bytes

Contents

module Clarion
  module ConstFinder
    def self.find(const, prefix, name)
      retried = false
      constant_name = name.to_s.gsub(/\A.|_./) { |s| s[-1].upcase }

      begin
        const.const_get constant_name, false
      rescue NameError
        unless retried
          begin
            require "#{prefix}/#{name}"
          rescue LoadError
          end

          retried = true
          retry
        end

        nil
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
clarion-1.1.0 lib/clarion/const_finder.rb
clarion-1.0.0 lib/clarion/const_finder.rb
clarion-0.3.0 lib/clarion/const_finder.rb
clarion-0.2.1 lib/clarion/const_finder.rb
clarion-0.2.0 lib/clarion/const_finder.rb
clarion-0.1.0 lib/clarion/const_finder.rb