sequel_simple_callbacks 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/sequel_simple_callbacks.rb +35 -22
- data/sequel_simple_callbacks.gemspec +21 -31
- metadata +40 -57
- data/.gitignore +0 -23
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "sequel_simple_callbacks"
|
8
|
-
gem.summary = %Q[Sequel
|
8
|
+
gem.summary = %Q[Sequel Model plugin that enables ActiveRecord-compatible class-level before and after filter declarations for models with support for conditional execution]
|
9
9
|
gem.description = %Q[This plugin makes it possible to declare simple before and after callbacks on the class level just like ActiveRecord]
|
10
10
|
gem.email = "github@tadman.ca"
|
11
11
|
gem.homepage = "http://github.com/tadman/sequel_simple_callbacks"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -14,12 +14,43 @@ module SequelSimpleCallbacks
|
|
14
14
|
STANDARD_HOOKS = (Sequel::Model::HOOKS - SPECIAL_HOOKS).freeze
|
15
15
|
INSTALLABLE_HOOKS = (Sequel::Model::HOOKS + ADDITIONAL_HOOKS).freeze
|
16
16
|
|
17
|
-
def apply(model_class)
|
17
|
+
def self.apply(model_class)
|
18
18
|
end
|
19
19
|
|
20
|
-
def configure(model_class, *arguments, &block)
|
20
|
+
def self.configure(model_class, *arguments, &block)
|
21
|
+
self.define_callback_hooks(model_class)
|
21
22
|
end
|
22
|
-
|
23
|
+
|
24
|
+
def self.define_callback_hooks(model_class)
|
25
|
+
STANDARD_HOOKS.each do |hook|
|
26
|
+
pre_hook = nil
|
27
|
+
|
28
|
+
if (model_class.instance_methods.include?(hook))
|
29
|
+
pre_hook = :"_internal_#{hook}"
|
30
|
+
|
31
|
+
model_class.send(:alias_method, pre_hook, hook)
|
32
|
+
end
|
33
|
+
|
34
|
+
model_class.send(:define_method, hook) do
|
35
|
+
self.class.run_callbacks(self, hook)
|
36
|
+
|
37
|
+
self.send(pre_hook) if (pre_hook)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
SPECIAL_HOOKS.each do |hook|
|
42
|
+
model_class.send(:define_method, hook) do
|
43
|
+
self.class.run_callbacks(self, hook)
|
44
|
+
|
45
|
+
if (new?)
|
46
|
+
self.class.run_callbacks(self, :"#{hook}_on_create")
|
47
|
+
else
|
48
|
+
self.class.run_callbacks(self, :"#{hook}_on_update")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
23
54
|
module ClassMethods
|
24
55
|
# Add a callback hook to the model with parameters:
|
25
56
|
# * :if => One of [ Symbol, Proc ] (optional)
|
@@ -98,7 +129,7 @@ module SequelSimpleCallbacks
|
|
98
129
|
end
|
99
130
|
end
|
100
131
|
|
101
|
-
break if (
|
132
|
+
break if (false === result)
|
102
133
|
end
|
103
134
|
end
|
104
135
|
|
@@ -142,24 +173,6 @@ module SequelSimpleCallbacks
|
|
142
173
|
end
|
143
174
|
|
144
175
|
module InstanceMethods
|
145
|
-
STANDARD_HOOKS.each do |hook|
|
146
|
-
define_method(hook) do
|
147
|
-
self.class.run_callbacks(self, hook)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
SPECIAL_HOOKS.each do |hook|
|
152
|
-
define_method(hook) do
|
153
|
-
self.class.run_callbacks(self, hook)
|
154
|
-
|
155
|
-
if (new?)
|
156
|
-
self.class.run_callbacks(self, :"#{hook}_on_create")
|
157
|
-
else
|
158
|
-
self.class.run_callbacks(self, :"#{hook}_on_update")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
176
|
# This method is provided as a simple method to call arbitrary callback
|
164
177
|
# chains without having to run through the specific method
|
165
178
|
def run_callbacks(hook)
|
@@ -1,51 +1,41 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.1.
|
7
|
+
s.name = "sequel_simple_callbacks"
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["tadman"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2012-05-15"
|
13
|
+
s.description = "This plugin makes it possible to declare simple before and after callbacks on the class level just like ActiveRecord"
|
14
|
+
s.email = "github@tadman.ca"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"sequel_simple_callbacks.gemspec",
|
28
|
-
"test/helper.rb",
|
29
|
-
"test/models/conditional.rb",
|
30
|
-
"test/models/example.rb",
|
31
|
-
"test/models/model_triggers.rb",
|
32
|
-
"test/test_sequel_simple_callbacks.rb"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/tadman/sequel_simple_callbacks}
|
35
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.7}
|
38
|
-
s.summary = %q{Sequel Plugin to add ActiveRecord style callback declarations}
|
39
|
-
s.test_files = [
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/sequel_simple_callbacks.rb",
|
26
|
+
"sequel_simple_callbacks.gemspec",
|
40
27
|
"test/helper.rb",
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
"test/models/conditional.rb",
|
29
|
+
"test/models/example.rb",
|
30
|
+
"test/models/model_triggers.rb",
|
31
|
+
"test/test_sequel_simple_callbacks.rb"
|
45
32
|
]
|
33
|
+
s.homepage = "http://github.com/tadman/sequel_simple_callbacks"
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = "1.8.24"
|
36
|
+
s.summary = "Sequel Model plugin that enables ActiveRecord-compatible class-level before and after filter declarations for models with support for conditional execution"
|
46
37
|
|
47
38
|
if s.respond_to? :specification_version then
|
48
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
39
|
s.specification_version = 3
|
50
40
|
|
51
41
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
metadata
CHANGED
@@ -1,47 +1,42 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_simple_callbacks
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- tadman
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: sequel
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :development
|
32
|
-
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: This plugin makes it possible to declare simple before and after callbacks
|
31
|
+
on the class level just like ActiveRecord
|
34
32
|
email: github@tadman.ca
|
35
33
|
executables: []
|
36
|
-
|
37
34
|
extensions: []
|
38
|
-
|
39
|
-
extra_rdoc_files:
|
35
|
+
extra_rdoc_files:
|
40
36
|
- LICENSE
|
41
37
|
- README.rdoc
|
42
|
-
files:
|
38
|
+
files:
|
43
39
|
- .document
|
44
|
-
- .gitignore
|
45
40
|
- LICENSE
|
46
41
|
- README.rdoc
|
47
42
|
- Rakefile
|
@@ -53,41 +48,29 @@ files:
|
|
53
48
|
- test/models/example.rb
|
54
49
|
- test/models/model_triggers.rb
|
55
50
|
- test/test_sequel_simple_callbacks.rb
|
56
|
-
has_rdoc: true
|
57
51
|
homepage: http://github.com/tadman/sequel_simple_callbacks
|
58
52
|
licenses: []
|
59
|
-
|
60
53
|
post_install_message:
|
61
|
-
rdoc_options:
|
62
|
-
|
63
|
-
require_paths:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
64
56
|
- lib
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
58
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
72
|
-
version: "0"
|
73
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
64
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
- 0
|
80
|
-
version: "0"
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
81
69
|
requirements: []
|
82
|
-
|
83
70
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.8.24
|
85
72
|
signing_key:
|
86
73
|
specification_version: 3
|
87
|
-
summary: Sequel
|
88
|
-
|
89
|
-
|
90
|
-
- test/models/conditional.rb
|
91
|
-
- test/models/example.rb
|
92
|
-
- test/models/model_triggers.rb
|
93
|
-
- test/test_sequel_simple_callbacks.rb
|
74
|
+
summary: Sequel Model plugin that enables ActiveRecord-compatible class-level before
|
75
|
+
and after filter declarations for models with support for conditional execution
|
76
|
+
test_files: []
|