Module: Koala::Utils
Instance Attribute Summary collapse
-
#logger ⇒ Object
The Koala logger, an instance of the standard Ruby logger, pointing to STDOUT by default.
Instance Method Summary collapse
-
#deprecate(message) ⇒ Object
Prints a deprecation message.
-
#symbolize_hash(hash) ⇒ Object
Ensures that a hash uses symbols as opposed to strings Useful for allowing either syntax for end users.
Instance Attribute Details
#logger ⇒ Object
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.
15 16 17 |
# File 'lib/koala/utils.rb', line 15 def logger @logger end |
Instance Method Details
#deprecate(message) ⇒ Object
Prints a deprecation message. Each individual message will only be printed once to avoid spamming.
24 25 26 27 28 29 30 31 |
# File 'lib/koala/utils.rb', line 24 def deprecate() @posted_deprecations ||= [] unless @posted_deprecations.include?() # only include each message once Kernel.warn("#{DEPRECATION_PREFIX}#{}") @posted_deprecations << end end |
#symbolize_hash(hash) ⇒ Object
Ensures that a hash uses symbols as opposed to strings Useful for allowing either syntax for end users
35 36 37 38 39 |
# File 'lib/koala/utils.rb', line 35 def symbolize_hash(hash) return hash unless hash.is_a?(Hash) hash.inject({}){ |memo,(key,value)| memo[key.to_sym] = symbolize_hash(value); memo } end |