Module: EffectiveOrganizationsOrganization
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/effective_organizations_organization.rb
Overview
EffectiveOrganizationsOrganization
Mark your category model with effective_organizations_organization to get all the includes
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary collapse
-
#build_representative(user:) ⇒ Object
Find or build.
- #representative(user:) ⇒ Object
-
#to_s ⇒ Object
Instance Methods.
- #users ⇒ Object
Instance Method Details
#build_representative(user:) ⇒ Object
Find or build
65 66 67 |
# File 'app/models/concerns/effective_organizations_organization.rb', line 65 def build_representative(user:) representative(user: user) || representatives.build(user: user) end |
#representative(user:) ⇒ Object
60 61 62 |
# File 'app/models/concerns/effective_organizations_organization.rb', line 60 def representative(user:) representatives.find { |rep| rep.user_id == user.id } end |
#to_s ⇒ Object
Instance Methods
56 57 58 |
# File 'app/models/concerns/effective_organizations_organization.rb', line 56 def to_s title.presence || 'organization' end |
#users ⇒ Object
69 70 71 |
# File 'app/models/concerns/effective_organizations_organization.rb', line 69 def users representatives.reject(&:marked_for_destruction?).map(&:user) end |