Module: EffectiveMembershipsOrganization

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/effective_memberships_organization.rb

Overview

EffectiveMembershipsOrganization

Mark your category model with effective_memberships_organization to get all the includes

Defined Under Namespace

Modules: Base, ClassMethods

Instance Method Summary collapse

Instance Method Details

#build_representative(user:) ⇒ Object

Find or build



92
93
94
# File 'app/models/concerns/effective_memberships_organization.rb', line 92

def build_representative(user:)
  representative(user: user) || representatives.build(user: user)
end

#membership_present?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'app/models/concerns/effective_memberships_organization.rb', line 79

def membership_present?
  membership.present? && !membership.marked_for_destruction?
end

#membership_usersObject



100
101
102
# File 'app/models/concerns/effective_memberships_organization.rb', line 100

def membership_users
  users.select { |user| user.is?(:member) && !user.archived? }
end

#outstanding_fee_payment_feesObject



83
84
85
# File 'app/models/concerns/effective_memberships_organization.rb', line 83

def outstanding_fee_payment_fees
  fees.select { |fee| fee.fee_payment_fee? && !fee.purchased? }
end

#representative(user:) ⇒ Object



87
88
89
# File 'app/models/concerns/effective_memberships_organization.rb', line 87

def representative(user:)
  representatives.find { |rep| rep.user_id == user.id }
end

#to_sObject

Instance Methods



75
76
77
# File 'app/models/concerns/effective_memberships_organization.rb', line 75

def to_s
  title.presence || 'organization'
end

#usersObject



96
97
98
# File 'app/models/concerns/effective_memberships_organization.rb', line 96

def users
  representatives.reject(&:marked_for_destruction?).map(&:user)
end