groupify 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/groupify/adapter/active_record.rb +34 -32
- data/lib/groupify/adapter/mongoid.rb +27 -25
- data/lib/groupify/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6c1b6a28b9ffcb7a8fd8cdd22c7882e68b7fc33
|
4
|
+
data.tar.gz: 1b828c4275ba593ff14e4813117047faf668082b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abffefbf67162095c5943df53b394b1adb4bcf846e78909b37fec2e3b26db2d21e7c0bab6ae1f5888a6d280e1061590fb5968556d5d1b05255fce7bd37531226
|
7
|
+
data.tar.gz: c9db57ffa507fb16e2606fa2fd1bdb245d120e18cf66148d37a014a88b578b36ee4e1d679e35e21d9da6015c633c7e50cc778b346f4e1fd086e67e40d97eb1ea
|
@@ -4,44 +4,46 @@ require 'set'
|
|
4
4
|
# Groups and members
|
5
5
|
module Groupify
|
6
6
|
module ActiveRecord
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
module Adapter
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
# Define a scope that returns nothing.
|
12
|
+
# This is built into ActiveRecord 4, but not 3
|
13
|
+
unless self.class.respond_to? :none
|
14
|
+
def self.none
|
15
|
+
where(arel_table[:id].eq(nil).and(arel_table[:id].not_eq(nil)))
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
include Groupify::ActiveRecord::Group
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
def acts_as_group(opts = {})
|
22
|
+
include Groupify::ActiveRecord::Group
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
if (member_klass = opts.delete :default_members)
|
25
|
+
self.default_member_class = member_klass.to_s.classify.constantize
|
26
|
+
end
|
27
|
+
|
28
|
+
if (member_klasses = opts.delete :members)
|
29
|
+
member_klasses.each do |member_klass|
|
30
|
+
has_members(member_klass)
|
31
|
+
end
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
def acts_as_group_member(opts = {})
|
36
|
+
@group_class_name = opts[:class_name] || 'Group'
|
37
|
+
include Groupify::ActiveRecord::GroupMember
|
38
|
+
end
|
39
|
+
|
40
|
+
def acts_as_named_group_member(opts = {})
|
41
|
+
include Groupify::ActiveRecord::NamedGroupMember
|
31
42
|
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def acts_as_group_member(opts = {})
|
35
|
-
@group_class_name = opts[:class_name] || 'Group'
|
36
|
-
include Groupify::ActiveRecord::GroupMember
|
37
|
-
end
|
38
|
-
|
39
|
-
def acts_as_named_group_member(opts = {})
|
40
|
-
include Groupify::ActiveRecord::NamedGroupMember
|
41
|
-
end
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
def acts_as_group_membership(opts = {})
|
45
|
+
include Groupify::ActiveRecord::GroupMembership
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
@@ -325,4 +327,4 @@ module Groupify
|
|
325
327
|
end
|
326
328
|
end
|
327
329
|
|
328
|
-
ActiveRecord::Base.send :include, Groupify::ActiveRecord
|
330
|
+
ActiveRecord::Base.send :include, Groupify::ActiveRecord::Adapter
|
@@ -4,35 +4,37 @@ require 'set'
|
|
4
4
|
# Groups and members
|
5
5
|
module Groupify
|
6
6
|
module Mongoid
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
module Adapter
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
def none; where(:id => nil); end
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def acts_as_group(opts = {})
|
16
|
+
include Groupify::Mongoid::Group
|
17
|
+
|
18
|
+
if (member_klass = opts.delete :default_members)
|
19
|
+
self.default_member_class = member_klass.to_s.classify.constantize
|
20
|
+
end
|
21
|
+
|
22
|
+
if (member_klasses = opts.delete :members)
|
23
|
+
member_klasses.each do |member_klass|
|
24
|
+
has_members(member_klass)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
16
28
|
|
17
|
-
|
18
|
-
|
29
|
+
def acts_as_group_member(opts = {})
|
30
|
+
@group_class_name = opts[:class_name] || 'Group'
|
31
|
+
include Groupify::Mongoid::GroupMember
|
19
32
|
end
|
20
33
|
|
21
|
-
|
22
|
-
|
23
|
-
has_members(member_klass)
|
24
|
-
end
|
34
|
+
def acts_as_named_group_member(opts = {})
|
35
|
+
include Groupify::Mongoid::NamedGroupMember
|
25
36
|
end
|
26
37
|
end
|
27
|
-
|
28
|
-
def acts_as_group_member(opts = {})
|
29
|
-
@group_class_name = opts[:class_name] || 'Group'
|
30
|
-
include Groupify::Mongoid::GroupMember
|
31
|
-
end
|
32
|
-
|
33
|
-
def acts_as_named_group_member(opts = {})
|
34
|
-
include Groupify::Mongoid::NamedGroupMember
|
35
|
-
end
|
36
38
|
end
|
37
39
|
|
38
40
|
# Usage:
|
@@ -249,4 +251,4 @@ module Groupify
|
|
249
251
|
end
|
250
252
|
end
|
251
253
|
|
252
|
-
Mongoid::Document.send :include, Groupify::Mongoid
|
254
|
+
Mongoid::Document.send :include, Groupify::Mongoid::Adapter
|
data/lib/groupify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dwbutler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.2.1
|
156
|
+
rubygems_version: 2.2.0.rc.1
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Group functionality for Rails
|