mongoid_param 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +6 -0
- data/VERSION +1 -1
- data/lib/mongoid_param.rb +2 -1
- data/spec/models/post.rb +5 -0
- data/spec/mongoid_param_spec.rb +5 -0
- metadata +4 -4
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/mongoid_param.rb
CHANGED
@@ -14,6 +14,7 @@ module Mongoid
|
|
14
14
|
self.param_fields = on_fields
|
15
15
|
field :_param, :type => String
|
16
16
|
index :_param, :unique => true
|
17
|
+
scope :param_is, lambda {|p| where(:_param => p) }
|
17
18
|
validates :_param, :presence => true, :uniqueness => true,
|
18
19
|
:format => { :with => /[-a-z0-9_]+/ },
|
19
20
|
:exclusion => { :in => %w[index show new create edit update destroy delete] }
|
@@ -35,7 +36,7 @@ module Mongoid
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def to_param
|
38
|
-
_param
|
39
|
+
_param_was || _param
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
data/spec/models/post.rb
CHANGED
data/spec/mongoid_param_spec.rb
CHANGED
@@ -68,6 +68,11 @@ describe Mongoid::Param do
|
|
68
68
|
p.blank?.should eql false
|
69
69
|
end
|
70
70
|
|
71
|
+
it "finds by scope" do
|
72
|
+
p = Post.param_is('2010_6_21_big_announcement').active.first
|
73
|
+
p.blank?.should eql false
|
74
|
+
end
|
75
|
+
|
71
76
|
it "does not find nonexistent things" do
|
72
77
|
p = Post.find_by_param('2010_5_3_some_post')
|
73
78
|
p.blank?.should eql true
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_param
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jason Coene
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-12 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|