jchupp-is_paranoid 0.8.0 → 0.8.1
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/VERSION.yml +1 -1
- data/lib/is_paranoid.rb +9 -6
- data/spec/is_paranoid_spec.rb +9 -2
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/is_paranoid.rb
CHANGED
@@ -119,12 +119,15 @@ module IsParanoid
|
|
119
119
|
|
120
120
|
self.class.send(
|
121
121
|
:include,
|
122
|
-
Module.new{
|
123
|
-
define_method name do |*args|
|
124
|
-
parent_klass.
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
Module.new{ # Example:
|
123
|
+
define_method name do |*args| # def android_with_destroyed
|
124
|
+
parent_klass.first_with_destroyed( # Android.first_with_destroyed(
|
125
|
+
:conditions => { # :conditions => {
|
126
|
+
parent_klass.primary_key => # :id =>
|
127
|
+
self.send(assoc.primary_key_name) # self.send(:android_id)
|
128
|
+
} # }
|
129
|
+
) # )
|
130
|
+
end # end
|
128
131
|
}
|
129
132
|
)
|
130
133
|
self.send(name, *args)
|
data/spec/is_paranoid_spec.rb
CHANGED
@@ -167,8 +167,8 @@ describe IsParanoid do
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
-
describe '
|
171
|
-
it "should be able to access destroyed parents
|
170
|
+
describe '(parent)_with_destroyed' do
|
171
|
+
it "should be able to access destroyed parents" do
|
172
172
|
# Memory is has_many with a non-default primary key
|
173
173
|
# Sticker is a has_one with a default primary key
|
174
174
|
[Memory, Sticker].each do |klass|
|
@@ -182,6 +182,13 @@ describe IsParanoid do
|
|
182
182
|
instance.android_with_destroyed.should == parent
|
183
183
|
end
|
184
184
|
end
|
185
|
+
|
186
|
+
it "should return nil if no destroyed parent exists" do
|
187
|
+
sticker = Sticker.new(:name => 'Rainbows')
|
188
|
+
# because the default relationship works this way, i.e.
|
189
|
+
sticker.android.should == nil
|
190
|
+
sticker.android_with_destroyed.should == nil
|
191
|
+
end
|
185
192
|
end
|
186
193
|
|
187
194
|
describe 'alternate fields and field values' do
|