From ed00e3ffe2ced6fe41d405c7034c75764e64dff9 Mon Sep 17 00:00:00 2001 From: Geoff Harcourt Date: Tue, 31 Dec 2013 14:51:24 -0500 Subject: [PATCH] Use more concise declaration of DEFAULT_CACHE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In response to @acnalesso’s notes on e3f86c80512afc7fda4c98b753c7b103331731b1, 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. --- app/models/impressionist/impressionable.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/impressionist/impressionable.rb b/app/models/impressionist/impressionable.rb index 76a2b9f..32152cc 100644 --- a/app/models/impressionist/impressionable.rb +++ b/app/models/impressionist/impressionable.rb @@ -5,13 +5,11 @@ module Impressionist module ClassMethods attr_accessor :impressionist_cache_options - unless defined?(DEFAULT_CACHE) - DEFAULT_CACHE = { - :counter_cache => false, - :column_name => :impressions_count, - :unique => false - } - end + DEFAULT_CACHE ||= { + :counter_cache => false, + :column_name => :impressions_count, + :unique => false + } def impressionist_counter_cache_options @impressionist_cache_options ||= {}