mongoid_taggable 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTlhZmEwYzJlMGFiNjA5MGM5YWE1ZTNmMThiMGQ0MDZkMDUyYzk0MQ==
4
+ MGU1ODdmNDExYTQ4ZGYwNjYyNGU1MjBiNzE2ODdjNGI4ZmRjZGJhYg==
5
5
  data.tar.gz: !binary |-
6
- OTQxZjU4MDQ1ZTY1ZDI2MWNlYTA1NzRiM2Y0NTlkMzE4M2MxZmM5Yw==
6
+ ZTA1MGJlYzllYTM1MjRjNGQ3NDc5ZWNhOWNjMDYzNDg4ZTRiOWQzYQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDkwMzM0MjU1YTFlY2RjMGVjMGJjN2EwZTdiNWMzYWYxM2ZmNmJiZGYzODRm
10
- ZTFlNWE5MjA2NTc0NGRjOGIyNDBmZTI5MzM2ZDI1N2FhYmU2OGVkOTFiNGJi
11
- MjFiNTcxYTNmNjY5MzNmM2I3M2E0ZjQ0Y2I0ZTRlZWU2ODNlMmM=
9
+ ZGJmMjBiYTRmNjI1MTYwZWI0YzE3ODdjYTAwYThiODg4ZjM1Y2QyYjhhYzdm
10
+ ZmI2ODU2NzgwYjVmMmFhODQxNWE3NTEwZTY3MjhkZDMzMWY2OGY2YzBmZWRh
11
+ Y2MwNDFlZTE4YjkyZjY0OTAyNjgzNWM5M2ZmMmU5OTg4ZGUyZjk=
12
12
  data.tar.gz: !binary |-
13
- YzdlMzNiZmZiMTJhZDFjOTk3ZjEwM2Y0M2MyNzJmZGFhMmE1ZmY1YjkxMTE4
14
- OGVlMTExMTRiOWNjOGFhMzJkMDQ1NzYxNGVhYWY4MmRiODRlNTY1M2Q0ODgy
15
- ZTViNTg4ODI5NTJlMWQwZmVlOWEwOWMwZTA0NDc5ODM4OWRlYzU=
13
+ ZDUxMmJkYzg1ODg4ZGEzMTZjZmI5MWExYzAwZGEwODFhNWViYjIxMzIwYTJi
14
+ Yjc4ZWIzZGYyYmViNzQ0ZjVhMjMyNDRlNjU4MWY3OGQ5YWMyN2RiODA4ZWI5
15
+ MGFiMmU2NjVkZGYxYjA5YzZlYmI5YTJiMmYyNTM1OTZlNWI5MjM=
@@ -13,26 +13,20 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module Mongoid::Taggable
16
- def self.included(base)
16
+ extend ActiveSupport::Concern
17
+
18
+ included do
17
19
  # create fields for tags and index it
18
- base.field :tags_array, :type => Array, :default => []
19
- base.index tags_array: 1 #[['tags_array', Mongo::ASCENDING]]
20
+ field :tags_array, :type => Array, :default => []
21
+ index({ tags_array: 1 })
20
22
 
21
23
  # add callback to save tags index
22
- base.after_save do |document|
23
- if document.tags_array_changed
24
- document.class.save_tags_index!
25
- document.tags_array_changed = false
26
- end
24
+ after_save do |document|
25
+ document.class.save_tags_index! if document.tags_array_changed?
27
26
  end
28
27
 
29
- # extend model
30
- base.extend ClassMethods
31
- base.send :include, InstanceMethods
32
- base.send :attr_accessor, :tags_array_changed
33
-
34
28
  # enable indexing as default
35
- base.enable_tags_index!
29
+ enable_tags_index!
36
30
  end
37
31
 
38
32
  module ClassMethods
@@ -111,22 +105,20 @@ module Mongoid::Taggable
111
105
  end
112
106
  end
113
107
 
114
- module InstanceMethods
115
- def tags
116
- (tags_array || []).join(self.class.tags_separator)
117
- end
118
108
 
119
- def tags=(tags)
120
- if tags.present?
121
- self.tags_array = tags.split(self.class.tags_separator).map(&:strip).reject(&:blank?)
122
- else
123
- self.tags_array = []
124
- end
125
- @tags_array_changed = true
126
- end
109
+ def tags
110
+ (tags_array || []).join(self.class.tags_separator)
111
+ end
127
112
 
128
- def save_tags_index!
129
- self.class.save_tags_index!
113
+ def tags=(tags)
114
+ if tags.present?
115
+ self.tags_array = tags.split(self.class.tags_separator).map(&:strip).reject(&:blank?)
116
+ else
117
+ self.tags_array = []
130
118
  end
131
119
  end
120
+
121
+ def save_tags_index!
122
+ self.class.save_tags_index!
123
+ end
132
124
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |g|
6
6
  g.name = 'mongoid_taggable'
7
- g.version = '1.1.0'
7
+ g.version = '1.1.1'
8
8
  g.date = '2013-03-22'
9
9
  g.description = %q{Mongoid Taggable provides some helpers to create taggable documents.}
10
10
  g.summary = %q{Mongoid taggable behaviour}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_taggable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wilker Lucio