rocket_cms_mongoid 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfc6bfc1b1f48c302b1eac3c48b996cb72542f85
4
- data.tar.gz: 9067bf73d8a28181c8a7fd2885e4cc227a3356c3
3
+ metadata.gz: 33a3aa57ec9d0b26188a7c3657a1ba764b690c83
4
+ data.tar.gz: 8674ea11aa6d1cc0cced3cb05c5873d7049cdd73
5
5
  SHA512:
6
- metadata.gz: 3e26ad34bbcc12a1a1ff966d4015e8ceae2161626b162f99369c564e08e1de5d17b5510c2dad0e0789eef53a11b68c1437651f8121917f63488eeb47ed871e39
7
- data.tar.gz: 564ad607bc0b58f484bb1fd403e70c5a416c6124d6d054b3e8548fa8306dfd8e08e6934713f78c1efc209484fe7f1bcd8f5a718927bfe18b0dc103c37ba4137a
6
+ metadata.gz: 86f76be1739e03049b8cdef37047cf2b9e64cb1d641db189ef24ec3f3ddad5aca991a9cf614df420ebb45acf5bf5111a0b50ec509e638dd174207ea57b6e1ab9
7
+ data.tar.gz: 9cb672463555ce66a78e9cc8b4abcd0141c65cc8e11068583fda7edf2f58e3f7516e834645cbc70e4c50da329eb2fc147ca36f149e15d6464a26581357540ac8
@@ -0,0 +1,38 @@
1
+ module ManualSlug
2
+ extend ActiveSupport::Concern
3
+ include Mongoid::Slug
4
+
5
+ def text_slug
6
+ self._slugs.empty? ? '' : self._slugs.last
7
+ end
8
+ def text_slug=(slug)
9
+ if slug.blank?
10
+ self._slugs = []
11
+ else
12
+ self._slugs.delete(slug)
13
+ self._slugs << slug
14
+ end
15
+ end
16
+
17
+ module ClassMethods
18
+ def manual_slug(field, options = {}, callback = true)
19
+ options.merge!(permanent: true, history: true)
20
+ slug field, options
21
+
22
+ # we will create slugs manually when needed
23
+ skip_callback :create, :before, :build_slug
24
+
25
+ before_validation do
26
+ self._slugs = self._slugs.map{ |s| s.strip }.select {|s| !s.blank? }
27
+
28
+ if self._slugs.empty?
29
+ self.build_slug
30
+ end
31
+
32
+ true
33
+ end if callback
34
+ end
35
+ end
36
+
37
+ end
38
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocket_cms_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.5.6
75
+ version: 0.5.7
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 0.5.6
82
+ version: 0.5.7
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: glebtv-mongoid_nested_set
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +144,7 @@ extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
146
  - lib/rocket_cms_mongoid.rb
147
+ - lib/rocket_cms_mongoid/manual_slug.rb
147
148
  homepage: https://github.com/rs-pro/rocket_cms
148
149
  licenses:
149
150
  - MIT