Skip to content

Commit

Permalink
Avoid method name clash with ActiveRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
andys committed Feb 4, 2012
1 parent b9393f9 commit 2175c41
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,6 @@


v0.4. Avoid method name clash with ActiveRecord

v0.3. Support bang and question mark method rewrites v0.3. Support bang and question mark method rewrites


v0.2. Support disabling cache on timeout v0.2. Support disabling cache on timeout
Expand Down
4 changes: 2 additions & 2 deletions README
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Example


class User < ActiveRecord::Base class User < ActiveRecord::Base


cache do redis_cache do
def fullname def fullname
firstname + ' ' + lastname firstname + ' ' + lastname
end end
Expand All @@ -33,7 +33,7 @@ Redrecord can be used to cache attributes that use assocations:
class User < ActiveRecord::Base class User < ActiveRecord::Base
has_many :preferences has_many :preferences


cache do redis_cache do
def preferences_list def preferences_list
preferences.map(&:name).join(', ') preferences.map(&:name).join(', ')
end end
Expand Down
2 changes: 1 addition & 1 deletion lib/redrecord.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def redrecord_invalidation_fields
@redrecord_invalidation_fields ||= [] @redrecord_invalidation_fields ||= []
end end


def cache(*fields, &bl) def redis_cache(*fields, &bl)
if block_given? if block_given?
old_methods = instance_methods old_methods = instance_methods
class_eval(&bl) class_eval(&bl)
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def initialize(id, first_name=nil, last_name=nil)
@id, @first_name, @last_name = id, first_name, last_name @id, @first_name, @last_name = id, first_name, last_name
end end


cache do redis_cache do
def full_name def full_name
@recalculated = true @recalculated = true
"#{first_name} #{last_name}" "#{first_name} #{last_name}"
Expand Down

0 comments on commit 2175c41

Please sign in to comment.