mm-learnup-sluggable 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/Rakefile +1 -1
  3. data/lib/mm-learnup-sluggable.rb +11 -15
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGU1ZjZmMmQ1Mzc2NzY5NWU2MTQwNjdiMGNmMTEzYjUxZWEzNTZlMA==
4
+ MTg1OTNkZjgzYjg5MmM4NGI3YmM2OTc3ZmJiYzA2ZWQ5NTljZWRkNw==
5
5
  data.tar.gz: !binary |-
6
- MGQzZjE4YzJlYTAxZDNlNGNkM2E4NzgwNzkyYTQ4MTc1ZTBiZDczYg==
6
+ Y2YzNzVkMDRkMDQxZGYyM2I2NWU2MWZjMWNkYmVhNDRkODFlYzljZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzhmNjllYTNhNGNmMTA2MTU3NDhiMzBiZmVhNjNmYjM0MzY0MzA2MGEwZTZj
10
- NjU2NTM0NDI1MDIwNWQ4YTZkZDY1NzRlYjNhOTE5M2JhMzc4OTNiNjZkZDQ5
11
- NGE1YzdlMmM2NjYxNmQxMjhkOTBhMTgyNzNkNjBkN2Y3ODRlZmM=
9
+ OGFlOTc0MDg5YWYyYTJmMWFlNzVhNWUwZTFiMDU3ODQ4ZWQ4Mjk5YzQ2Yjcx
10
+ ZGE5NWY3Y2U1MjA3ZDRlOGMxNGMyOTg3ZGIxYjI2Zjg1ZTQ0MzFjNGU1NWZl
11
+ NGQ0Mzc0MjQ2M2VhODQ0ZTQ0ZTAxOTFhZTRkMzEyODcxYTA2YjI=
12
12
  data.tar.gz: !binary |-
13
- M2MzOWZjNjQ0M2VkZjBkNzgzZmNiMjZkMDNiMmQ5OWQyMGJjYmUyZjliODUy
14
- YWIwYzUwMjhiZmQ3Y2ViMWVjM2QyMTYzYzQyNmI1MjYwNWUwMzlkNzRhZDE1
15
- MWJhOWI3NWVkNzgyZDI5ZjM3NjY3YTE2OGYxNWUzNjcyNGRlYzc=
13
+ YTBlOGM0MzAzNzdjZDkzMTAwYjQxZGVhNmE1ODFkNDc2ZmFjNTY1ODFiZDFk
14
+ OGVjNTJiMmU1ZTVlYzljMjdlYjhmMTc0ZmVjMWFmOTAwNWJmMmQ4ZDlkM2Uy
15
+ ZjMwNzZiMGJlYWI0MGJkZTg5MjkzNTI2MjQzMDg5NTgzOWY5OTA=
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.3"
22
+ s.version = "0.3.5"
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"
@@ -20,6 +20,16 @@ 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
+
23
33
  def find_by_slug!(slug)
24
34
  if obj = find_by_slug(slug)
25
35
  obj
@@ -61,6 +71,7 @@ module MongoMapper
61
71
  self.send(slug_options[:callback], :set_slug)
62
72
 
63
73
  slug_key = self.slug_options[:key]
74
+ @_slug_key = slug_key
64
75
 
65
76
  define_method :to_param do
66
77
  self.send(slug_key).blank? ? self.id.to_s : self.send(slug_key)
@@ -86,21 +97,6 @@ module MongoMapper
86
97
  # value.respond_to?(:downcase) ? value.downcase : value
87
98
  # end
88
99
 
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
- elsif obj = where(slug_key => /^#{Regexp.escape(slug)}$/i).first
97
- raise old_slug_exception(slug, obj)
98
- else
99
- nil
100
- end
101
- end
102
- end
103
-
104
100
  before_update do
105
101
  if self.send("#{slug_key}_changed?")
106
102
  self.old_slugs = self.old_slugs.reject { |slug| slug == self.send(slug_key) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mm-learnup-sluggable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-10 00:00:00.000000000 Z
11
+ date: 2015-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo_mapper
@@ -70,9 +70,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project:
73
- rubygems_version: 2.2.2
73
+ rubygems_version: 2.4.5
74
74
  signing_key:
75
- specification_version: 3
75
+ specification_version: 4
76
76
  summary: MongoMapper plugin to cache a slugged version of a field. Originally forked
77
77
  from mm-learnup-sluggable.
78
78
  test_files: []