module Shoulda::Matchers::Util
@private
Public Class Methods
deconstantize(path)
click to toggle source
# File lib/shoulda/matchers/util.rb, line 5 def self.deconstantize(path) if defined?(ActiveSupport::Inflector) && ActiveSupport::Inflector.respond_to?(:deconstantize) ActiveSupport::Inflector.deconstantize(path) else path.to_s[0...(path.to_s.rindex('::') || 0)] end end
indent(string, width)
click to toggle source
# File lib/shoulda/matchers/util.rb, line 27 def self.indent(string, width) indentation = ' ' * width string.split(/[\n\r]/).map { |line| indentation + line }.join("\n") end
safe_constantize(camel_cased_word)
click to toggle source
# File lib/shoulda/matchers/util.rb, line 14 def self.safe_constantize(camel_cased_word) if defined?(ActiveSupport::Inflector) && ActiveSupport::Inflector.respond_to?(:safe_constantize) ActiveSupport::Inflector.safe_constantize(camel_cased_word) else begin camel_cased_word.constantize rescue NameError nil end end end