slugged 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/slugged/slug.rb +16 -6
- data/lib/slugged/version.rb +1 -1
- metadata +3 -3
data/lib/slugged/slug.rb
CHANGED
@@ -9,8 +9,22 @@ module Slugged
|
|
9
9
|
scope :for_record, lambda { |r| where(:record_id => r.id, :scope => Slugged.key_for_scope(r)) }
|
10
10
|
scope :for_slug, lambda { |scope, slug| where(:scope=> scope.to_s, :slug => slug.to_s)}
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
if methods.include? :pluck
|
13
|
+
def self.id_for(scope, slug)
|
14
|
+
ordered.for_slug(scope, slug).pluck(:record_id).first
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.previous_for(record)
|
18
|
+
ordered.only_slug.for_record(record).pluck(:slug)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
def self.id_for(scope, slug)
|
22
|
+
ordered.for_slug(scope, slug).first.try(:record_id)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.previous_for(record)
|
26
|
+
ordered.only_slug.for_record(record).all.map(&:slug)
|
27
|
+
end
|
14
28
|
end
|
15
29
|
|
16
30
|
def self.record_slug(record, slug)
|
@@ -20,10 +34,6 @@ module Slugged
|
|
20
34
|
create :scope => scope, :record_id => record.id, :slug => slug.to_s
|
21
35
|
end
|
22
36
|
|
23
|
-
def self.previous_for(record)
|
24
|
-
ordered.only_slug.for_record(record).all.map(&:slug)
|
25
|
-
end
|
26
|
-
|
27
37
|
def self.remove_history_for(record)
|
28
38
|
for_record(record).delete_all
|
29
39
|
end
|
data/lib/slugged/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slugged
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Darcy Laycock
|