Use more concise declaration of DEFAULT_CACHE

In response to @acnalesso’s notes on
e3f86c8051, using ||= to make assignment
of Impressionable::ClassMethods::DEFAULT_CACHE more concise, avoiding a
call to #defined? when checking to see if the constant has been
declared.
This commit is contained in:
Geoff Harcourt 2013-12-31 14:51:24 -05:00
parent e3f86c8051
commit ed00e3ffe2
1 changed files with 5 additions and 7 deletions

View File

@ -5,13 +5,11 @@ module Impressionist
module ClassMethods module ClassMethods
attr_accessor :impressionist_cache_options attr_accessor :impressionist_cache_options
unless defined?(DEFAULT_CACHE) DEFAULT_CACHE ||= {
DEFAULT_CACHE = {
:counter_cache => false, :counter_cache => false,
:column_name => :impressions_count, :column_name => :impressions_count,
:unique => false :unique => false
} }
end
def impressionist_counter_cache_options def impressionist_counter_cache_options
@impressionist_cache_options ||= {} @impressionist_cache_options ||= {}