projects
/
feedcatcher.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Merged updates from trunk into stable branch
[feedcatcher.git]
/
vendor
/
rails
/
activerecord
/
lib
/
active_record
/
dynamic_scope_match.rb
1
module
ActiveRecord
2
class
DynamicScopeMatch
3
def self
.
match
(
method
)
4
ds_match
=
self
.
new
(
method
)
5
ds_match
.
scope
?
ds_match
:
nil
6
end
7
8
def
initialize
(
method
)
9
@scope
=
true
10
case
method
.
to_s
11
when
/^scoped_by_([_a-zA-Z]\w*)$/
12
names
=
$1
13
else
14
@scope
=
nil
15
end
16
@attribute_names
=
names
&&
names
.
split
(
'_and_'
)
17
end
18
19
attr_reader
:scope
,
:attribute_names
20
21
def
scope
?
22
!
@scope
.
nil
?
23
end
24
end
25
end