Module: EffectiveOrganizationsUser
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/effective_organizations_user.rb
Overview
EffectiveOrganizationsUser
Mark your user model with effective_organizations_user to get all the includes
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary collapse
-
#build_representative(organization:) ⇒ Object
Find or build.
- #organizations ⇒ Object
-
#representative(organization:) ⇒ Object
Instance Methods.
Instance Method Details
#build_representative(organization:) ⇒ Object
Find or build
32 33 34 |
# File 'app/models/concerns/effective_organizations_user.rb', line 32 def build_representative(organization:) representative(organization: organization) || representatives.build(organization: organization) end |
#organizations ⇒ Object
36 37 38 |
# File 'app/models/concerns/effective_organizations_user.rb', line 36 def organizations representatives.reject(&:marked_for_destruction?).map(&:organization) end |
#representative(organization:) ⇒ Object
Instance Methods
27 28 29 |
# File 'app/models/concerns/effective_organizations_user.rb', line 27 def representative(organization:) representatives.find { |rep| rep.organization_id == organization.id } end |