Skip to content

Commit

Permalink
Merge pull request #442 from seuros/master
Browse files Browse the repository at this point in the history
[MIsc] Reduced method's name length
  • Loading branch information
bf4 committed Dec 27, 2013
2 parents 5f87304 + 6b9ed18 commit 74d4254
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ def self.included(base)
# has any "cached_#{tag_type}_list" column
base.instance_eval do
# @private
def _has_acts_as_taggable_on_cache_columns?(db_columns)
def _has_tags_cache_columns?(db_columns)
db_column_names = db_columns.map(&:name)
tag_types.any? {|context|
db_column_names.include?("cached_#{context.to_s.singularize}_list")
}
end

# @private
def _add_acts_as_taggable_on_caching_methods
def _add_tags_caching_methods
send :include, ActsAsTaggableOn::Taggable::Cache::InstanceMethods
extend ActsAsTaggableOn::Taggable::Cache::ClassMethods

before_save :save_cached_tag_list

initialize_acts_as_taggable_on_cache
initialize_tags_cache
end

# ActiveRecord::Base.columns makes a database connection and caches the calculated
Expand All @@ -32,8 +32,8 @@ def _add_acts_as_taggable_on_caching_methods
def columns
@acts_as_taggable_on_columns ||= begin
db_columns = super
if _has_acts_as_taggable_on_cache_columns?(db_columns)
_add_acts_as_taggable_on_caching_methods
if _has_tags_cache_columns?(db_columns)
_add_tags_caching_methods
end
db_columns
end
Expand All @@ -43,7 +43,7 @@ def columns
end

module ClassMethods
def initialize_acts_as_taggable_on_cache
def initialize_tags_cache
tag_types.map(&:to_s).each do |tag_type|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def self.caching_#{tag_type.singularize}_list?
Expand All @@ -55,7 +55,7 @@ def self.caching_#{tag_type.singularize}_list?

def acts_as_taggable_on(*args)
super(*args)
initialize_acts_as_taggable_on_cache
initialize_tags_cache
end

def caching_tag_list_on?(context)
Expand Down

0 comments on commit 74d4254

Please sign in to comment.