sequel_sluggable 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sequel_sluggable.rb +8 -0
- data/lib/version.rb +1 -1
- data/sequel_sluggable.gemspec +2 -2
- data/spec/sequel_sluggable_spec.rb +18 -0
- metadata +2 -2
data/lib/sequel_sluggable.rb
CHANGED
@@ -31,6 +31,14 @@ module Sequel
|
|
31
31
|
self[@sluggable_options[:target] => value.chomp]
|
32
32
|
end
|
33
33
|
|
34
|
+
# Propagate settings to the child classes
|
35
|
+
#
|
36
|
+
# @param [Class] Child class
|
37
|
+
def inherited(klass)
|
38
|
+
super
|
39
|
+
klass.sluggable_options = self.sluggable_options.dup
|
40
|
+
end
|
41
|
+
|
34
42
|
# Set the plugin options
|
35
43
|
#
|
36
44
|
# Options:
|
data/lib/version.rb
CHANGED
data/sequel_sluggable.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sequel_sluggable}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Pavel Kunc"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-16}
|
13
13
|
s.description = %q{Sequel plugin which provides Slug functionality for model.}
|
14
14
|
s.email = %q{pavel.kunc@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -62,6 +62,24 @@ describe "SequelSluggable" do
|
|
62
62
|
class Item < Sequel::Model; end
|
63
63
|
lambda { Item.plugin :sluggable, :source => :name, :sluggator => 'xy' }.should raise_error(ArgumentError, "If you provide :sluggator it must be Symbol or callable.")
|
64
64
|
end
|
65
|
+
|
66
|
+
it "should preserve options in sub classes" do
|
67
|
+
class SubItem < Item; end
|
68
|
+
SubItem.sluggable_options.should_not be_nil
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should allow to change options for sub class" do
|
72
|
+
class SubItem < Item; end
|
73
|
+
SubItem.plugin :sluggable, :source => :test
|
74
|
+
SubItem.sluggable_options[:source].should eql :test
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should not mess with parent settings when inherited" do
|
78
|
+
class SubItem < Item; end
|
79
|
+
SubItem.sluggable_options[:source] = :test
|
80
|
+
SubItem.sluggable_options[:source].should eql :test
|
81
|
+
Item.sluggable_options[:source].should eql :name
|
82
|
+
end
|
65
83
|
end
|
66
84
|
|
67
85
|
describe "::find_by_pk_or_slug" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_sluggable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kunc
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-16 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|