effective_organizations 0.0.5 → 0.0.6
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: a2ee1cb9ffc7df883ea343966168245ab3d77ba59ef9753a20d825702ba46aaa
|
4
|
+
data.tar.gz: fcd8f65d9dbc66c5073077e6bd7fe9f48774c4444d965c7c4ce95d09c3d97935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a34485e30e3d66f85cb4dff1ed2ccd6656134ac5171c2ceae64e8fc30336144c1ac6c9889dab98b018dbdad0c2b3bda96e583f70583a9907f09eaf1ed4ebe1a0
|
7
|
+
data.tar.gz: fb7e677000619da597b0b43f5ae827211d2d55fca0d51326559b27bb7fc7fbd7b3155260afa37f7768360a0f695d2d80667dabc680414f2479582c645c438dac
|
@@ -32,6 +32,8 @@ module EffectiveOrganizationsOrganization
|
|
32
32
|
has_many :representatives, -> { Effective::Representative.sorted },
|
33
33
|
class_name: 'Effective::Representative', inverse_of: :organization, dependent: :delete_all
|
34
34
|
|
35
|
+
accepts_nested_attributes_for :representatives, allow_destroy: true
|
36
|
+
|
35
37
|
has_many :users, through: :representatives,
|
36
38
|
source_type: (@effective_organizations_organization_opts[:users_source_type] || (name.start_with?('Effective') ? '::User' : "#{name.split('::').first}::Organization"))
|
37
39
|
|
@@ -58,4 +60,13 @@ module EffectiveOrganizationsOrganization
|
|
58
60
|
title.presence || 'New Organization'
|
59
61
|
end
|
60
62
|
|
63
|
+
def representative(user:)
|
64
|
+
representatives.find { |rep| rep.user_id == user.id }
|
65
|
+
end
|
66
|
+
|
67
|
+
# Find or build
|
68
|
+
def build_representative(user:)
|
69
|
+
representative(user: user) || representatives.build(user: user)
|
70
|
+
end
|
71
|
+
|
61
72
|
end
|
@@ -24,6 +24,8 @@ module EffectiveOrganizationsUser
|
|
24
24
|
has_many :representatives, -> { Effective::Representative.sorted },
|
25
25
|
class_name: 'Effective::Representative', inverse_of: :user, dependent: :delete_all
|
26
26
|
|
27
|
+
accepts_nested_attributes_for :representatives, allow_destroy: true
|
28
|
+
|
27
29
|
# App scoped
|
28
30
|
has_many :organizations, through: :representatives,
|
29
31
|
source_type: @effective_organizations_user_opts[:organizations_source_type] || "#{name.split('::').first}::Organization"
|
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.6
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|