effective_organizations 0.0.6 → 0.0.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cacbee4a7dd40f4151038a00c39b0e7ef134f0ec739ee29753bc8aa34a73dc8c
|
4
|
+
data.tar.gz: 38e3039961b2ff7ceff0b66090370c9ace3f54ab6f16c666cdc68ca82b699d03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd0fd64f099a8a15adb96f3d7d0be5952e4a371f33beddab08427491b818fdcfd12484c376fceb8f0b468ed88423cd47f95c39f8bd9d45e14d2f51c98071b7fa
|
7
|
+
data.tar.gz: 5a69fcb0b32b336e92cfe714c4641e1f38b7a549080e11e20c27031320a9a661d02c06fb7567831f04e105c0f7b9f3c1f4ee003342d67b0a05e4348317feffd9
|
@@ -6,11 +6,7 @@ module EffectiveOrganizationsOrganization
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
module Base
|
9
|
-
def effective_organizations_organization
|
10
|
-
@effective_organizations_organization_opts = {
|
11
|
-
users_source_type: users_source_type
|
12
|
-
}
|
13
|
-
|
9
|
+
def effective_organizations_organization
|
14
10
|
include ::EffectiveOrganizationsOrganization
|
15
11
|
end
|
16
12
|
end
|
@@ -34,9 +30,6 @@ module EffectiveOrganizationsOrganization
|
|
34
30
|
|
35
31
|
accepts_nested_attributes_for :representatives, allow_destroy: true
|
36
32
|
|
37
|
-
has_many :users, through: :representatives,
|
38
|
-
source_type: (@effective_organizations_organization_opts[:users_source_type] || (name.start_with?('Effective') ? '::User' : "#{name.split('::').first}::Organization"))
|
39
|
-
|
40
33
|
effective_resource do
|
41
34
|
title :string
|
42
35
|
category :string
|
@@ -56,10 +49,6 @@ module EffectiveOrganizationsOrganization
|
|
56
49
|
|
57
50
|
# Instance Methods
|
58
51
|
|
59
|
-
def to_s
|
60
|
-
title.presence || 'New Organization'
|
61
|
-
end
|
62
|
-
|
63
52
|
def representative(user:)
|
64
53
|
representatives.find { |rep| rep.user_id == user.id }
|
65
54
|
end
|
@@ -69,4 +58,8 @@ module EffectiveOrganizationsOrganization
|
|
69
58
|
representative(user: user) || representatives.build(user: user)
|
70
59
|
end
|
71
60
|
|
61
|
+
def users
|
62
|
+
representatives.reject(&:marked_for_destruction?).map(&:user)
|
63
|
+
end
|
64
|
+
|
72
65
|
end
|
@@ -6,11 +6,7 @@ module EffectiveOrganizationsUser
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
module Base
|
9
|
-
def effective_organizations_user
|
10
|
-
@effective_organizations_user_opts = {
|
11
|
-
organizations_source_type: organizations_source_type
|
12
|
-
}
|
13
|
-
|
9
|
+
def effective_organizations_user
|
14
10
|
include ::EffectiveOrganizationsUser
|
15
11
|
end
|
16
12
|
end
|
@@ -20,19 +16,25 @@ module EffectiveOrganizationsUser
|
|
20
16
|
end
|
21
17
|
|
22
18
|
included do
|
23
|
-
# My teams
|
24
19
|
has_many :representatives, -> { Effective::Representative.sorted },
|
25
20
|
class_name: 'Effective::Representative', inverse_of: :user, dependent: :delete_all
|
26
21
|
|
27
22
|
accepts_nested_attributes_for :representatives, allow_destroy: true
|
28
|
-
|
29
|
-
# App scoped
|
30
|
-
has_many :organizations, through: :representatives,
|
31
|
-
source_type: @effective_organizations_user_opts[:organizations_source_type] || "#{name.split('::').first}::Organization"
|
32
23
|
end
|
33
24
|
|
25
|
+
# Instance Methods
|
26
|
+
|
34
27
|
def representative(organization:)
|
35
28
|
representatives.find { |rep| rep.organization_id == organization.id }
|
36
29
|
end
|
37
30
|
|
31
|
+
# Find or build
|
32
|
+
def build_representative(organization:)
|
33
|
+
representative(organization: organization) || representatives.build(organization: organization)
|
34
|
+
end
|
35
|
+
|
36
|
+
def organizations
|
37
|
+
representatives.reject(&:marked_for_destruction?).map(&:organization)
|
38
|
+
end
|
39
|
+
|
38
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_organizations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|