Class: Effective::CommitteeMember

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/committee_member.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#committee_idsObject

Returns the value of attribute committee_ids.



7
8
9
# File 'app/models/effective/committee_member.rb', line 7

def committee_ids
  @committee_ids
end

#user_idsObject

Returns the value of attribute user_ids.



7
8
9
# File 'app/models/effective/committee_member.rb', line 7

def user_ids
  @user_ids
end

Instance Method Details

#active?(date: nil) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
74
75
76
77
# File 'app/models/effective/committee_member.rb', line 70

def active?(date: nil)
  return true if start_on.blank? && end_on.blank?

  date ||= Time.zone.now
  date = date.to_date if date.respond_to?(:to_date)

  (start_on..end_on).cover?(date)  # Endless ranges
end

#build_committee(attributes = {}) ⇒ Object



96
97
98
99
# File 'app/models/effective/committee_member.rb', line 96

def build_committee(attributes = {})
  raise('please assign committee_type first') if committee_type.blank?
  self.committee = committee_type.constantize.new(attributes)
end

#build_user(attributes = {}) ⇒ Object



91
92
93
94
# File 'app/models/effective/committee_member.rb', line 91

def build_user(attributes = {})
  raise('please assign user_type first') if user_type.blank?
  self.user = user_type.constantize.new(attributes)
end

#emailObject



66
67
68
# File 'app/models/effective/committee_member.rb', line 66

def email
  user.try(:email)
end

#expired?(date: nil) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
# File 'app/models/effective/committee_member.rb', line 79

def expired?(date: nil)
  active?(date: date) == false
end

#to_sObject



62
63
64
# File 'app/models/effective/committee_member.rb', line 62

def to_s
  user.to_s
end