simple_group 0.1.1 → 0.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f1b79e0f95379a33f17b1227b437f53032b140a
|
4
|
+
data.tar.gz: 7a7efe44591c5376652791bf4908e5131aa01023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65605cac5efaa68e755be72ac38508625f3288c5438432901cf26d41554998febea8dc7bf6a0bfd5301285c3fa9905f8cc19f67c7f7018200c58c93c78247756
|
7
|
+
data.tar.gz: 0ed9b29df1ed5728c41748b666dfda6cd0146728e714042923b5c3f8d52f11cc2dc123812f802cc28785329ab890f280e7bbafbf3d3c2c412751a6b3574ceb09
|
@@ -7,9 +7,11 @@ class SimpleGroupMigration < ActiveRecord::Migration
|
|
7
7
|
end
|
8
8
|
|
9
9
|
if ActiveRecord::VERSION::MAJOR < 4
|
10
|
-
add_index :
|
11
|
-
add_index :
|
10
|
+
add_index :simple_group_combinations, [:group_item_id, :group_item_type]
|
11
|
+
add_index :simple_group_combinations, [:group_id, :group_type]
|
12
12
|
end
|
13
|
+
add_index :simple_group_combinations, [:group_item_id, :group_item_type, :group_id, :group_type],
|
14
|
+
unique: true, name: :index_simple_group_combinations
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.down
|
data/lib/simple_group/group.rb
CHANGED
@@ -10,9 +10,18 @@ module SimpleGroup
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def include?(model)
|
14
|
+
raise SimpleGroup::GroupNotAllowError unless model.class.groupable?
|
15
|
+
SimpleGroup::Combination.exists?(group: self, group_item: model)
|
16
|
+
end
|
17
|
+
|
18
|
+
def exclude?(model)
|
19
|
+
!include?(model)
|
20
|
+
end
|
21
|
+
|
13
22
|
def add(model)
|
14
23
|
raise SimpleGroup::GroupNotAllowError unless model.class.groupable?
|
15
|
-
SimpleGroup::Combination.
|
24
|
+
SimpleGroup::Combination.new(group: self, group_item: model).save
|
16
25
|
end
|
17
26
|
|
18
27
|
def remove(model)
|
data/lib/simple_group/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_group
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toyoaki Oko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|