simple_callbacks 0.0.1 → 0.0.2
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.
@@ -33,23 +33,23 @@ module AWS
|
|
33
33
|
# version that runs a run_calbacks block and then delegates
|
34
34
|
# to the origin method.
|
35
35
|
update_without_callbacks = instance_method(:update)
|
36
|
-
define_method :update do
|
37
|
-
run_callbacks(:update){ update_without_callbacks.bind(self).() }
|
36
|
+
define_method :update do |*args|
|
37
|
+
run_callbacks(:update){ update_without_callbacks.bind(self).(*args) }
|
38
38
|
end
|
39
39
|
|
40
40
|
create_without_callbacks = instance_method(:create)
|
41
|
-
define_method :create do
|
42
|
-
run_callbacks(:create){ create_without_callbacks.bind(self).() }
|
41
|
+
define_method :create do |*args|
|
42
|
+
run_callbacks(:create){ create_without_callbacks.bind(self).(*args) }
|
43
43
|
end
|
44
44
|
|
45
45
|
save_without_callbacks = instance_method(:save)
|
46
|
-
define_method :save do
|
47
|
-
run_callbacks(:save){ save_without_callbacks.bind(self).() }
|
46
|
+
define_method :save do |*args|
|
47
|
+
run_callbacks(:save){ save_without_callbacks.bind(self).(*args) }
|
48
48
|
end
|
49
49
|
|
50
50
|
destroy_without_callbacks = instance_method(:destroy)
|
51
|
-
define_method :destroy do
|
52
|
-
run_callbacks(:destroy){ destroy_without_callbacks.bind(self).() }
|
51
|
+
define_method :destroy do |*args|
|
52
|
+
run_callbacks(:destroy){ destroy_without_callbacks.bind(self).(*args) }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -112,4 +112,25 @@ describe 'model validations' do
|
|
112
112
|
|
113
113
|
end
|
114
114
|
|
115
|
+
describe "in a model" do
|
116
|
+
class Event < AWS::Record::Model
|
117
|
+
string_attr :name
|
118
|
+
before_validation :test_func
|
119
|
+
end
|
120
|
+
|
121
|
+
before(:each) do
|
122
|
+
Event.create_domain
|
123
|
+
Event.each{|u| u.destroy }
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
it "should work" do
|
128
|
+
#pp (Event.methods - Kernel.methods).sort
|
129
|
+
e = Event.new :name => "test"
|
130
|
+
e.should_receive(:test_func)
|
131
|
+
e.save
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
115
136
|
end
|