onyx-cache-money 0.2.5.4 → 0.2.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cash/write_through.rb +5 -2
- data/spec/cash/write_through_spec.rb +16 -4
- metadata +1 -1
data/lib/cash/write_through.rb
CHANGED
@@ -36,8 +36,11 @@ module Cash
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def shallow_clone
|
39
|
-
clone =
|
40
|
-
clone.
|
39
|
+
clone = self.class.new
|
40
|
+
new_ancestors = (self.metaclass.ancestors - clone.class.ancestors).reverse
|
41
|
+
new_ancestors.each { |ancestor| clone.extend(ancestor) }
|
42
|
+
clone.instance_variable_set("@attributes", instance_variable_get(:@attributes))
|
43
|
+
clone.instance_variable_set("@new_record", new_record?)
|
41
44
|
clone
|
42
45
|
end
|
43
46
|
|
@@ -48,21 +48,33 @@ module Cash
|
|
48
48
|
story = Story.new(:title => 'I am lugubrious')
|
49
49
|
story.characters.build(:name => 'How am I holy?')
|
50
50
|
story.save!
|
51
|
-
Story.get("id/#{story.id}").first.characters.loaded?.
|
51
|
+
Story.get("id/#{story.id}").first.characters.loaded?.should_not be
|
52
52
|
end
|
53
53
|
|
54
54
|
it "caches extended behavior" do
|
55
55
|
story = Story.new(:title => 'I am special')
|
56
56
|
module SpecialBehavior
|
57
|
-
def special_behavior
|
58
|
-
'woo!'
|
59
|
-
end
|
57
|
+
def special_behavior; 'woo!'; end
|
60
58
|
end
|
61
59
|
story.extend(SpecialBehavior)
|
62
60
|
story.save!
|
63
61
|
Story.get("id/#{story.id}").first.special_behavior.should == 'woo!'
|
64
62
|
end
|
65
63
|
|
64
|
+
it "caches extended behavior in the right order" do
|
65
|
+
story = Story.new(:title => 'I am special')
|
66
|
+
module SpecialBehaviorOne
|
67
|
+
def special_behavior; 'one!'; end
|
68
|
+
end
|
69
|
+
module SpecialBehaviorTwo
|
70
|
+
def special_behavior; 'two!'; end
|
71
|
+
end
|
72
|
+
story.extend(SpecialBehaviorOne)
|
73
|
+
story.extend(SpecialBehaviorTwo)
|
74
|
+
story.save!
|
75
|
+
Story.get("id/#{story.id}").first.special_behavior.should == 'two!'
|
76
|
+
end
|
77
|
+
|
66
78
|
it 'increments the count' do
|
67
79
|
story = Story.create!(:title => "Sam")
|
68
80
|
Story.get("title/#{story.title}/count", :raw => true).should =~ /1/
|