nitro 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +218 -0
- data/INSTALL +3 -0
- data/README +4 -2
- data/Rakefile +150 -8
- data/benchmark/bench.rb +1 -1
- data/doc/AUTHORS +2 -8
- data/doc/RELEASES +63 -1
- data/examples/ajax/controller.rb +2 -2
- data/examples/ajax/public/index.xhtml +3 -1
- data/examples/ajax/run.rb +3 -3
- data/examples/blog/README +8 -0
- data/examples/blog/cache/entriesadmintrue +3 -0
- data/examples/blog/run.rb +38 -40
- data/examples/blog/src/blog.rb +2 -1
- data/examples/blog/src/controller.rb +40 -20
- data/examples/blog/src/mailer.rb +2 -2
- data/examples/blog/src/models/blog.rb +2 -1
- data/examples/blog/src/models/content.rb +4 -33
- data/examples/blog/src/views/error.xhtml +1 -1
- data/examples/blog/src/xsl/style.xsl +1 -1
- data/examples/blog/test/tc_blog.rb +43 -0
- data/examples/flash/run.rb +2 -2
- data/examples/no_xsl_blog/lib/blog.rb +1 -1
- data/examples/no_xsl_blog/lib/blog/controller.rb +26 -17
- data/examples/no_xsl_blog/lib/blog/model.rb +3 -3
- data/examples/no_xsl_blog/lib/blog/template.rb +1 -1
- data/examples/no_xsl_blog/lib/content.rb +3 -7
- data/examples/no_xsl_blog/run.rb +34 -34
- data/examples/tiny/public/deep/dir/hello.xhtml +2 -0
- data/examples/tiny/run.rb +2 -2
- data/examples/wee_style/run.rb +5 -3
- data/examples/why_wiki/run.rb +5 -3
- data/install.rb +1 -1
- data/lib/nitro.rb +10 -9
- data/lib/nitro/adapters/cgi.rb +27 -2
- data/lib/nitro/adapters/fastcgi.rb +6 -2
- data/lib/nitro/adapters/webrick.rb +11 -9
- data/lib/nitro/buffering.rb +2 -2
- data/lib/nitro/builders/atom.rb +78 -0
- data/lib/nitro/builders/form.rb +2 -2
- data/lib/nitro/builders/rss.rb +4 -4
- data/lib/nitro/builders/table.rb +2 -2
- data/lib/nitro/builders/xhtml.rb +5 -8
- data/lib/nitro/builders/xml.rb +38 -14
- data/lib/nitro/caching.rb +2 -2
- data/lib/nitro/caching/actions.rb +2 -2
- data/lib/nitro/caching/fragments.rb +2 -2
- data/lib/nitro/caching/invalidation.rb +2 -28
- data/lib/nitro/caching/output.rb +3 -3
- data/lib/nitro/caching/stores.rb +4 -4
- data/lib/nitro/conf.rb +11 -6
- data/lib/nitro/context.rb +2 -2
- data/lib/nitro/controller.rb +12 -7
- data/lib/nitro/cookie.rb +2 -2
- data/lib/nitro/dispatcher.rb +33 -40
- data/lib/nitro/environment.rb +1 -1
- data/lib/nitro/localization.rb +5 -7
- data/lib/nitro/mail.rb +2 -2
- data/lib/nitro/markup.rb +5 -5
- data/lib/nitro/output.rb +2 -2
- data/lib/nitro/part.rb +8 -5
- data/lib/nitro/render.rb +46 -45
- data/lib/nitro/request.rb +7 -6
- data/lib/nitro/response.rb +14 -5
- data/lib/nitro/routing.rb +2 -2
- data/lib/nitro/runner.rb +57 -17
- data/lib/nitro/scaffold.rb +14 -8
- data/lib/nitro/session.rb +7 -4
- data/lib/nitro/session/drb.rb +2 -2
- data/lib/nitro/session/drbserver.rb +2 -2
- data/lib/nitro/session/memory.rb +2 -2
- data/lib/nitro/shaders.rb +8 -7
- data/lib/nitro/simple.rb +4 -1
- data/lib/nitro/template.rb +8 -8
- data/lib/nitro/testing.rb +6 -0
- data/lib/nitro/testing/assertions.rb +102 -0
- data/lib/nitro/testing/context.rb +52 -0
- data/lib/nitro/testing/testcase.rb +55 -0
- data/lib/nitro/ui/pager.rb +3 -3
- data/lib/nitro/ui/popup.rb +8 -13
- data/lib/nitro/ui/tabs.rb +4 -10
- data/lib/nitro/uri.rb +7 -7
- data/proto/doc/README +1 -0
- data/proto/public/cgi.rb +5 -0
- data/proto/run.rb +2 -4
- data/test/nitro/adapters/tc_cgi.rb +1 -1
- data/test/nitro/adapters/tc_webrick.rb +1 -2
- data/test/nitro/builders/tc_atom.rb +26 -0
- data/test/nitro/builders/tc_rss.rb +3 -2
- data/test/nitro/builders/tc_table.rb +1 -1
- data/test/nitro/builders/tc_xhtml.rb +4 -3
- data/test/nitro/builders/tc_xml.rb +7 -7
- data/test/nitro/tc_context.rb +1 -1
- data/test/nitro/tc_controller.rb +5 -3
- data/test/nitro/tc_dispatcher.rb +19 -18
- data/test/nitro/tc_localization.rb +1 -1
- data/test/nitro/tc_mail.rb +1 -1
- data/test/nitro/tc_session.rb +1 -1
- data/test/nitro/tc_template.rb +1 -1
- data/test/nitro/tc_uri.rb +3 -4
- data/test/nitro/ui/tc_pager.rb +7 -7
- data/test/public/blog/inc1.xhtml +2 -0
- data/test/public/blog/inc2.xhtml +1 -0
- data/test/public/blog/list.xhtml +3 -0
- metadata +180 -203
- data/examples/blog/cache/entriesadmin +0 -12
- data/lib/nitro/cluster.rb +0 -218
- data/lib/nitro/component.rb +0 -15
- data/lib/nitro/filters.rb +0 -215
- data/lib/nitro/ui/date-select.rb +0 -69
- data/test/nitro/tc_filters.rb +0 -111
@@ -1,12 +0,0 @@
|
|
1
|
-
<div class="entry"><h2 class="date">March 28, 2005</h2><div class="post"><h3 class="title">kokok</h3>lalal<div class="footer">posted by George Moschovitis at <a href="view_entry/14">11:32 AM</a> | <a href="view_entry/14#comments">4 comments</a>.</div></div></div><div class="entry"><h2 class="date">March 28, 2005</h2><div class="post"><h3 class="title">UNCACHE</h3>it bastard<div class="footer">posted by at <a href="view_entry/13">11:31 AM</a> | <a href="view_entry/13#comments">0 comments</a>.</div></div></div><div class="entry"><h2 class="date">March 28, 2005</h2><div class="post"><h3 class="title">UNCACHE</h3>it bastard<div class="footer">posted by George Moschovitis at <a href="view_entry/12">11:26 AM</a> | <a href="view_entry/12#comments">0 comments</a>.</div></div></div><div class="pager">
|
2
|
-
<div class="last"><a href="/?__pgentries=4">Last</a></div>
|
3
|
-
<div class="next"><a href="/?__pgentries=2">Next</a></div>
|
4
|
-
<ul>
|
5
|
-
<li class="active">1</li>
|
6
|
-
|
7
|
-
<li><a href="/?__pgentries=2">2</a></li>
|
8
|
-
|
9
|
-
<li><a href="/?__pgentries=3">3</a></li>
|
10
|
-
|
11
|
-
<li><a href="/?__pgentries=4">4</a></li>
|
12
|
-
</ul><div class="clear">.</div></div>
|
data/lib/nitro/cluster.rb
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: cluster.rb 249 2005-02-04 14:03:00Z gmosx $
|
4
|
-
|
5
|
-
# WARNING: This is old code, not updated to work in the
|
6
|
-
# latest nitro release. Will be fixed ASAP.
|
7
|
-
|
8
|
-
$:.unshift 'lib'
|
9
|
-
|
10
|
-
require 'drb'
|
11
|
-
require 'monitor'
|
12
|
-
|
13
|
-
require 'nitro/application'
|
14
|
-
require 'nitro/server'
|
15
|
-
require 'glue/cache'
|
16
|
-
require 'nitro/server/session'
|
17
|
-
|
18
|
-
module N
|
19
|
-
|
20
|
-
# A Cluster manages the state of a collection of servers. The cluster
|
21
|
-
# synchronizes the servers and distributes the state. An older version
|
22
|
-
# used a polling system, ie: the servers polled the cluster to
|
23
|
-
# obtain the state. This version uses a push system, ie when the
|
24
|
-
# state is changed a delta is pushed to the clients.
|
25
|
-
#
|
26
|
-
# TODO: use Sync instead of Monitor
|
27
|
-
|
28
|
-
class Cluster < N::Application
|
29
|
-
|
30
|
-
# The CHash 'endpoint' resides in the Cluster server
|
31
|
-
|
32
|
-
class CHash < Hash
|
33
|
-
attr :mon
|
34
|
-
|
35
|
-
# drbobject for this hash (local)
|
36
|
-
|
37
|
-
attr_accessor :ldrb
|
38
|
-
|
39
|
-
# the cluster, use a cluster to implement a set
|
40
|
-
# (one server per drb_uri)
|
41
|
-
|
42
|
-
attr_accessor :cluster
|
43
|
-
|
44
|
-
#
|
45
|
-
|
46
|
-
def initialize(ldrb_uri = "druby://:8000")
|
47
|
-
@mon = Monitor.new
|
48
|
-
@ldrb = DRb.start_service(ldrb_uri, self)
|
49
|
-
@cluster = {}
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
|
54
|
-
def join(sdrb_uri)
|
55
|
-
@mon.synchronize {
|
56
|
-
cluster[sdrb_uri] = DRbObject.new(nil, sdrb_uri)
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
alias_method :old_set, :[]=
|
61
|
-
|
62
|
-
# Not really usefull
|
63
|
-
|
64
|
-
def []=(key, value)
|
65
|
-
# store the value (useful on server restarts)
|
66
|
-
@mon.synchronize {
|
67
|
-
old_set(key, value)
|
68
|
-
|
69
|
-
puts "CLUSTER #{key} = #{value}"
|
70
|
-
|
71
|
-
cluster.each { |uri, sdrb|
|
72
|
-
begin
|
73
|
-
sdrb.server_sync(key, value)
|
74
|
-
rescue => ex
|
75
|
-
Logger.error "Server at #{uri} is down, removing from cluster"
|
76
|
-
cluster.delete(uri)
|
77
|
-
end
|
78
|
-
}
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
# Use this, avoids syncing the original server, and avoids a
|
83
|
-
# nasty deadlock.
|
84
|
-
#
|
85
|
-
def cluster_sync(key, value, server_uri)
|
86
|
-
# store the value (useful on server restarts)
|
87
|
-
@mon.synchronize {
|
88
|
-
old_set(key, value)
|
89
|
-
|
90
|
-
puts "CLUSTER #{key} = #{value}"
|
91
|
-
|
92
|
-
cluster.each { |uri, sdrb|
|
93
|
-
begin
|
94
|
-
sdrb.server_sync(key, value) unless uri == server_uri
|
95
|
-
rescue => ex
|
96
|
-
Logger.error "Server at #{uri} is down, removing from cluster"
|
97
|
-
cluster.delete(uri)
|
98
|
-
end
|
99
|
-
}
|
100
|
-
}
|
101
|
-
end
|
102
|
-
|
103
|
-
def [](key)
|
104
|
-
@mon.synchronize {
|
105
|
-
puts "LOOKUP #{key}"
|
106
|
-
return super
|
107
|
-
}
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
# The SHash 'endpoint' resides in the App server
|
113
|
-
|
114
|
-
class SHash < Hash
|
115
|
-
attr :mon
|
116
|
-
|
117
|
-
# drbobject for this hash (local)
|
118
|
-
attr_accessor :ldrb
|
119
|
-
|
120
|
-
# drb for the cluster hash
|
121
|
-
attr_accessor :cdrb
|
122
|
-
|
123
|
-
# ldrb = local drb uri
|
124
|
-
# cdrb = cluster drb uri
|
125
|
-
|
126
|
-
def initialize(ldrb_uri = "druby://:9000", cdrb_uri = "druby://:8000")
|
127
|
-
@mon = Monitor.new
|
128
|
-
@ldrb_uri = ldrb_uri
|
129
|
-
@ldrb = DRb.start_service(ldrb_uri, self)
|
130
|
-
@cdrb = DRbObject.new(nil, cdrb_uri)
|
131
|
-
@cdrb.join(ldrb_uri)
|
132
|
-
end
|
133
|
-
|
134
|
-
alias_method :old_set, :[]=
|
135
|
-
|
136
|
-
#
|
137
|
-
#
|
138
|
-
def []=(key, value)
|
139
|
-
# store the value in the local hash
|
140
|
-
@mon.synchronize {
|
141
|
-
puts "LOCAL #{key} = #{value}"
|
142
|
-
old_set(key, value)
|
143
|
-
@cdrb.cluster_sync(key, value, @ldrb_uri)
|
144
|
-
}
|
145
|
-
end
|
146
|
-
|
147
|
-
# If the key is not found in the local hash, try the
|
148
|
-
# cluster hash.
|
149
|
-
#
|
150
|
-
def [](key)
|
151
|
-
@mon.synchronize {
|
152
|
-
unless value = super
|
153
|
-
value = @cdrb[key]
|
154
|
-
old_set(key, value)
|
155
|
-
end
|
156
|
-
return value
|
157
|
-
}
|
158
|
-
end
|
159
|
-
|
160
|
-
# Called by the cluster
|
161
|
-
#
|
162
|
-
def server_sync(key, value)
|
163
|
-
puts "SYNC #{key} = #{value}"
|
164
|
-
@mon.synchronize {
|
165
|
-
old_set(key, value)
|
166
|
-
}
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
# Cluster Last Modified Hash
|
172
|
-
|
173
|
-
class Clm < CHash
|
174
|
-
def [](key)
|
175
|
-
@mon.synchronize {
|
176
|
-
unless value = super
|
177
|
-
puts "INIT #{key}"
|
178
|
-
value = Time.now.to_i
|
179
|
-
old_set(key, value)
|
180
|
-
end
|
181
|
-
return value
|
182
|
-
}
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
# = Slm Server Last Modified Hash
|
187
|
-
|
188
|
-
class Slm < SHash
|
189
|
-
def set!(key, lm = nil)
|
190
|
-
lm = Time.now.to_i unless lm
|
191
|
-
self[key] = lm
|
192
|
-
return lm
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def initialize(name = "Cluster")
|
197
|
-
super
|
198
|
-
end
|
199
|
-
|
200
|
-
def run
|
201
|
-
N::Cluster::Clm.new
|
202
|
-
DRb.start_service("druby://:8001", N::SessionManager.new)
|
203
|
-
|
204
|
-
while true
|
205
|
-
sleep(5000)
|
206
|
-
end
|
207
|
-
|
208
|
-
super
|
209
|
-
end
|
210
|
-
|
211
|
-
end
|
212
|
-
|
213
|
-
end
|
214
|
-
|
215
|
-
if $0 == __FILE__
|
216
|
-
require 'logger'
|
217
|
-
N::Cluster.new.exec()
|
218
|
-
end
|
data/lib/nitro/component.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: component.rb 266 2005-02-28 14:50:48Z gmosx $
|
4
|
-
|
5
|
-
require 'nitro/controller'
|
6
|
-
|
7
|
-
module N
|
8
|
-
|
9
|
-
# A Web Component. A Component extends from the
|
10
|
-
# base controller class.
|
11
|
-
|
12
|
-
class Component < Controller
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
data/lib/nitro/filters.rb
DELETED
@@ -1,215 +0,0 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: filters.rb 335 2005-03-31 14:02:02Z gmosx $
|
4
|
-
|
5
|
-
module N
|
6
|
-
|
7
|
-
# Filtering functionality for renders.
|
8
|
-
# The design and implementation is HEAVILY influenced
|
9
|
-
# by Rails.
|
10
|
-
#
|
11
|
-
# === Examples
|
12
|
-
#
|
13
|
-
# Filter as class:
|
14
|
-
#
|
15
|
-
# class TouchFilter
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# Filter
|
19
|
-
# before
|
20
|
-
# filter
|
21
|
-
# after
|
22
|
-
#
|
23
|
-
#--
|
24
|
-
# TODO: rethink what happens with module filters.
|
25
|
-
#++
|
26
|
-
|
27
|
-
module Filtering
|
28
|
-
|
29
|
-
# Store the code and the metadata (options) for
|
30
|
-
# the a Filter.
|
31
|
-
|
32
|
-
Filter = Struct.new(:code, :options)
|
33
|
-
|
34
|
-
def self.append_features(base)
|
35
|
-
super
|
36
|
-
base.extend(ClassMethods)
|
37
|
-
base.class_eval %{
|
38
|
-
@before_filters = []
|
39
|
-
|
40
|
-
def self.before_filters
|
41
|
-
@before_filters
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.before_filters=(bf)
|
45
|
-
@before_filters = bf
|
46
|
-
end
|
47
|
-
|
48
|
-
@after_filters = []
|
49
|
-
|
50
|
-
def self.after_filters
|
51
|
-
@after_filters
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.after_filters=(af)
|
55
|
-
@after_filters = af
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.inherited(sub)
|
59
|
-
super
|
60
|
-
sub.before_filters = self.before_filters.dup
|
61
|
-
sub.after_filters = self.after_filters.dup
|
62
|
-
end
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
module ClassMethods
|
67
|
-
|
68
|
-
# Prepend a filter to the before_filters collection.
|
69
|
-
|
70
|
-
def prepend_before_filter(*args, &block)
|
71
|
-
options = args.pop if args.last.is_a?(Hash)
|
72
|
-
|
73
|
-
if block_given?
|
74
|
-
filters = [ Filter.new(block, options) ]
|
75
|
-
else
|
76
|
-
filters = args.collect { |c| Filter.new(c, options) }
|
77
|
-
end
|
78
|
-
|
79
|
-
self.before_filters = filters + self.before_filters
|
80
|
-
end
|
81
|
-
|
82
|
-
# Append a filter to the before_filters collection.
|
83
|
-
|
84
|
-
def append_before_filter(*args, &block)
|
85
|
-
options = args.pop if args.last.is_a?(Hash)
|
86
|
-
|
87
|
-
if block_given?
|
88
|
-
filters = [ Filter.new(block, options) ]
|
89
|
-
else
|
90
|
-
filters = args.collect { |c| Filter.new(c, options) }
|
91
|
-
end
|
92
|
-
|
93
|
-
self.before_filters = self.before_filters + filters
|
94
|
-
end
|
95
|
-
|
96
|
-
# Alias for the most common case.
|
97
|
-
|
98
|
-
alias :before_filter :prepend_before_filter
|
99
|
-
|
100
|
-
# Prepend a filter to the after_filters collection.
|
101
|
-
|
102
|
-
def prepend_after_filter(*args, &block)
|
103
|
-
options = args.pop if args.last.is_a?(Hash)
|
104
|
-
|
105
|
-
if block_given?
|
106
|
-
filters = [ Filter.new(block, options) ]
|
107
|
-
else
|
108
|
-
filters = args.collect { |c| Filter.new(c, options) }
|
109
|
-
end
|
110
|
-
|
111
|
-
self.after_filters = filters + self.after_filters
|
112
|
-
end
|
113
|
-
|
114
|
-
# Append a filter to the after_filters collection.
|
115
|
-
|
116
|
-
def append_after_filter(*args, &block)
|
117
|
-
options = args.pop if args.last.is_a?(Hash)
|
118
|
-
|
119
|
-
if block_given?
|
120
|
-
filters = [ Filter.new(block, options) ]
|
121
|
-
else
|
122
|
-
filters = args.collect { |c| Filter.new(c, options) }
|
123
|
-
end
|
124
|
-
|
125
|
-
self.after_filters = self.after_filters + filters
|
126
|
-
end
|
127
|
-
|
128
|
-
# Alias for the most common case.
|
129
|
-
|
130
|
-
alias :after_filter :append_after_filter
|
131
|
-
|
132
|
-
# Install an arround Filter. A filter is a class that
|
133
|
-
# responds to the before and after methods. Both methods
|
134
|
-
# are prepended to the respective lists.
|
135
|
-
|
136
|
-
def prepend_arround_filter(*args)
|
137
|
-
options = args.pop if args.last.is_a?(Hash)
|
138
|
-
|
139
|
-
filters = [options].flatten
|
140
|
-
|
141
|
-
for filter in filters
|
142
|
-
if filter.respond_to?(:before)
|
143
|
-
prepend_before_filter(options) { |c| filter.before(c) }
|
144
|
-
elsif filter.respond_to?(:filter)
|
145
|
-
# consider 'filter' as synonym of before.
|
146
|
-
prepend_before_filter(options) { |c| filter.filter(c) }
|
147
|
-
end
|
148
|
-
prepend_after_filter(options) { |c| filter.after(c) } if filter.respond_to?(:after)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
# Install an arround Filter. A filter is a class that responds
|
153
|
-
# to the before and after methods. Both methods are appended to
|
154
|
-
# the respective lists.
|
155
|
-
|
156
|
-
def append_arround_filter(*args)
|
157
|
-
options = args.pop if args.last.is_a?(Hash)
|
158
|
-
|
159
|
-
filters = [filters].flatten
|
160
|
-
|
161
|
-
for filter in filters
|
162
|
-
if filter.respond_to?(:before)
|
163
|
-
append_before_filter(options) { |c| filter.before(c) }
|
164
|
-
elsif filter.respond_to?(:filter)
|
165
|
-
# consider 'filter' as synonym of before.
|
166
|
-
append_before_filter(options) { |c| filter.filter(c) }
|
167
|
-
end
|
168
|
-
append_after_filter(options) { |c| filter.after(c) } if filter.respond_to?(:after)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
# Alias for the most common case.
|
173
|
-
alias :filter :append_arround_filter
|
174
|
-
|
175
|
-
# Generates the code to call the filters
|
176
|
-
|
177
|
-
def gen_filters_call_code(action, filters) # :nodoc:
|
178
|
-
code = ""
|
179
|
-
|
180
|
-
for filter in filters
|
181
|
-
|
182
|
-
if options = filter.options
|
183
|
-
if only = options[:only]
|
184
|
-
next unless [only].flatten.include?(action.to_sym)
|
185
|
-
elsif except = options[:except]
|
186
|
-
next if [except].flatten.include?(action.to_sym)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
filter = filter.code
|
191
|
-
|
192
|
-
if Symbol === filter
|
193
|
-
code << "if #{filter} == false then return false end;"
|
194
|
-
elsif String === filter
|
195
|
-
code << "#{filter};"
|
196
|
-
elsif filter.respond_to?('call') && (filter.arity == 1 || filter.arity == -1)
|
197
|
-
code << 'if filter.call(self) == false then return false end;'
|
198
|
-
elsif filter.is_a?(Module) and filter.instance_methods.size > 0
|
199
|
-
class_eval "include #{filter};"
|
200
|
-
meth = filter.instance_methods[0]
|
201
|
-
code << "if #{meth} == false then return false end;"
|
202
|
-
elsif filter.respond_to?('filter')
|
203
|
-
code << "if #{filter}.filter(self) == false then return false end"
|
204
|
-
else
|
205
|
-
raise 'Valid filters are either a Symbol, a String or a Proc/Method.'
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
return code
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
end
|
214
|
-
|
215
|
-
end
|