module Koala::Utils
Constants
- DEPRECATION_PREFIX
@private
Attributes
logger[RW]
The Koala
logger, an instance of the standard Ruby logger, pointing to STDOUT by default. In Rails projects, you can set this to Rails.logger.
Public Instance Methods
deprecate(message)
click to toggle source
Prints a deprecation message. Each individual message will only be printed once to avoid spamming.
# File lib/koala/utils.rb 24 def deprecate(message) 25 @posted_deprecations ||= [] 26 unless @posted_deprecations.include?(message) 27 # only include each message once 28 Kernel.warn("#{DEPRECATION_PREFIX}#{message}") 29 @posted_deprecations << message 30 end 31 end
symbolize_hash(hash)
click to toggle source
Ensures that a hash uses symbols as opposed to strings Useful for allowing either syntax for end users
# File lib/koala/utils.rb 35 def symbolize_hash(hash) 36 return hash unless hash.is_a?(Hash) 37 38 hash.inject({}){ |memo,(key,value)| memo[key.to_sym] = symbolize_hash(value); memo } 39 end