active-record-without-callbacks 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -1
- data/VERSION +1 -1
- data/active-record-without-callbacks.gemspec +60 -0
- data/lib/active-record-without-callbacks.rb +3 -4
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
= active-record-without-callbacks
|
2
2
|
|
3
|
-
|
3
|
+
It is pretty straight forward:
|
4
|
+
require 'rubygems'
|
5
|
+
require 'active-record-without-callbacks'
|
6
|
+
|
7
|
+
ActiveRecordWithoutCallbacks.wo_callbacks(MyModel) do
|
8
|
+
model = MyModel.new(:name => "Kasper")
|
9
|
+
model.save! #No callbacks will be executed!
|
10
|
+
end
|
11
|
+
|
12
|
+
model = MyModel.new(:name => "Christina")
|
13
|
+
model.save! #Callbacks will be executed!
|
4
14
|
|
5
15
|
== Contributing to active-record-without-callbacks
|
6
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "active-record-without-callbacks"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kasper Johansen"]
|
12
|
+
s.date = "2013-04-05"
|
13
|
+
s.description = "A method that allows you to run code without callbacks for a specific active-record model."
|
14
|
+
s.email = "kj@gfish.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"active-record-without-callbacks.gemspec",
|
29
|
+
"lib/active-record-without-callbacks.rb",
|
30
|
+
"spec/active-record-without-callbacks_spec.rb",
|
31
|
+
"spec/spec_helper.rb"
|
32
|
+
]
|
33
|
+
s.homepage = "http://github.com/kaspernj/active-record-without-callbacks"
|
34
|
+
s.licenses = ["MIT"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = "1.8.25"
|
37
|
+
s.summary = "A method that allows you to run code without callbacks for a specific active-record model."
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
s.specification_version = 3
|
41
|
+
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
44
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
45
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
46
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
49
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
50
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
51
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
55
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
56
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -11,12 +11,11 @@ class ActiveRecordWithoutCallbacks
|
|
11
11
|
#Store previous value for restoring later.
|
12
12
|
saved << {
|
13
13
|
:take => take,
|
14
|
-
:value => klass.__send__(take)
|
14
|
+
:value => klass.__send__(take)
|
15
15
|
}
|
16
16
|
|
17
17
|
#Clear all callbacks.
|
18
|
-
|
19
|
-
klass.__send__(take).clear
|
18
|
+
klass.__send__("#{take}=", [])
|
20
19
|
|
21
20
|
raise "Expected '#{take}' to be empty but it wasnt: #{klass.__send__(take)}" unless klass.__send__(take).empty?
|
22
21
|
end
|
@@ -26,7 +25,7 @@ class ActiveRecordWithoutCallbacks
|
|
26
25
|
ensure
|
27
26
|
#Restore previous callbacks.
|
28
27
|
saved.each do |save|
|
29
|
-
klass.__send__(save[:take]
|
28
|
+
klass.__send__("#{save[:take]}=", save[:value])
|
30
29
|
end
|
31
30
|
end
|
32
31
|
#end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-record-without-callbacks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- README.rdoc
|
93
93
|
- Rakefile
|
94
94
|
- VERSION
|
95
|
+
- active-record-without-callbacks.gemspec
|
95
96
|
- lib/active-record-without-callbacks.rb
|
96
97
|
- spec/active-record-without-callbacks_spec.rb
|
97
98
|
- spec/spec_helper.rb
|
@@ -110,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
111
|
version: '0'
|
111
112
|
segments:
|
112
113
|
- 0
|
113
|
-
hash: -
|
114
|
+
hash: -4039996256379877821
|
114
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
116
|
none: false
|
116
117
|
requirements:
|