mm-learnup-sluggable 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Rakefile +1 -1
- data/lib/mm-learnup-sluggable.rb +13 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmU0N2FiYjAzNGYwNTg3OGNkOTI0ZGZlNTk4OWMwNzM3MzIzZTlkMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzYxMzg4OTFiZmE1NTQwNmNiOWI3NWIzOTZkYzAxYmM3YTNhNGY2NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTc4NGYxMDBhOGQ1MjdlNGQzOWZkMWQyOTEyNGY2NmUyYjkyMzA4YmM1OTRk
|
10
|
+
NDRjZWZlODljNWZlNzllNDA0NDk2MjMzMjBjNDhiOTZjNmNlZjI1Yzg1ZTE2
|
11
|
+
MjBkYmQwNGM4MGM4YTUyZGU2NzQ4MGI4MmUwYjZjOTNlNzdiMWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzlkOTY1MTVhNjI0ZmZhMzNkMDZlZmRkZDhhOGY3ZTU0ZmE4ZmY0YWEyMTEw
|
14
|
+
NWJjZDE1MGZhYjAwOGEyOTUyMDA5NDBiMGRlMWYyOWQxYmUxOGUxYTNlNzNj
|
15
|
+
NzYxNzBmNzVjYTQ0N2Y3YWMyYjdjNjAxOGI4ZjMyNTcxYjU0NzM=
|
data/Rakefile
CHANGED
@@ -19,7 +19,7 @@ spec = Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
# Change these as appropriate
|
21
21
|
s.name = "mm-learnup-sluggable"
|
22
|
-
s.version = "0.3.
|
22
|
+
s.version = "0.3.6"
|
23
23
|
s.summary = "MongoMapper plugin to cache a slugged version of a field. Originally forked from mm-learnup-sluggable."
|
24
24
|
s.author = "Scott Taylor"
|
25
25
|
s.email = "scott@railsnewbie.com"
|
data/lib/mm-learnup-sluggable.rb
CHANGED
@@ -20,16 +20,6 @@ module MongoMapper
|
|
20
20
|
error
|
21
21
|
end
|
22
22
|
|
23
|
-
def find_by_slug(slug)
|
24
|
-
if obj = where(@_slug_key => slug).first
|
25
|
-
obj
|
26
|
-
elsif obj = where(:old_slugs => slug).first
|
27
|
-
raise old_slug_exception(slug, obj)
|
28
|
-
else
|
29
|
-
nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
23
|
def find_by_slug!(slug)
|
34
24
|
if obj = find_by_slug(slug)
|
35
25
|
obj
|
@@ -71,7 +61,6 @@ module MongoMapper
|
|
71
61
|
self.send(slug_options[:callback], :set_slug)
|
72
62
|
|
73
63
|
slug_key = self.slug_options[:key]
|
74
|
-
@_slug_key = slug_key
|
75
64
|
|
76
65
|
define_method :to_param do
|
77
66
|
self.send(slug_key).blank? ? self.id.to_s : self.send(slug_key)
|
@@ -97,6 +86,19 @@ module MongoMapper
|
|
97
86
|
# value.respond_to?(:downcase) ? value.downcase : value
|
98
87
|
# end
|
99
88
|
|
89
|
+
metaclass = class << self; self; end
|
90
|
+
metaclass.class_eval do
|
91
|
+
define_method :find_by_slug do |slug|
|
92
|
+
if obj = where(slug_key => slug).first
|
93
|
+
obj
|
94
|
+
elsif obj = where(:old_slugs => slug).first
|
95
|
+
raise old_slug_exception(slug, obj)
|
96
|
+
else
|
97
|
+
nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
100
102
|
before_update do
|
101
103
|
if self.send("#{slug_key}_changed?")
|
102
104
|
self.old_slugs = self.old_slugs.reject { |slug| slug == self.send(slug_key) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mm-learnup-sluggable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Taylor
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.4.
|
73
|
+
rubygems_version: 2.4.6
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: MongoMapper plugin to cache a slugged version of a field. Originally forked
|