Permalink
Browse files

Fixed the naming of the counter index property.

  • Loading branch information...
1 parent 9965816 commit 22def5b88a601382e2fa40e5afbb6b1ff358cdd6 @postmodern committed Jul 17, 2010
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/dm-is-counter_cacheable/is/counter_cacheable.rb
@@ -37,12 +37,12 @@ def counter_cacheable(relationship_name,options={})
raise(RuntimeError,"unknown relationship #{relationship_name} in #{self}",caller)
end
- if options.has_key?(:counter_property)
- counter_property = options[:counter_property]
- else
- model_name = self.name.split('::').last
- counter_property = (DataMapper::NamingConventions::Resource::UnderscoredAndPluralized.call(model_name) + '_counter').to_sym
- end
+ model_name = DataMapper::NamingConventions::Resource::UnderscoredAndPluralized.call(self.name.split('::').last)
+ counter_property = if options.has_key?(:counter_property)
+ options[:counter_property]
+ else
+ :"#{model_name}_counter"
+ end
relationship = self.relationships[relationship_name]
parent_model = case relationship
@@ -54,7 +54,7 @@ def counter_cacheable(relationship_name,options={})
parent_model.property counter_property, Integer, :default => 0, :min => 0
if options[:counter_index]
- counter_index = :"#{counter_property}_index"
+ counter_index = :"#{relationship_name}_#{model_name}_index"
self.property counter_index, Integer, :min => 1
else

0 comments on commit 22def5b

Please sign in to comment.