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)


64
65
66
67
68
69
70
71
# File 'app/models/effective/committee_member.rb', line 64

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



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

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



85
86
87
88
# File 'app/models/effective/committee_member.rb', line 85

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

#expired?(date: nil) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'app/models/effective/committee_member.rb', line 73

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

#to_sObject



60
61
62
# File 'app/models/effective/committee_member.rb', line 60

def to_s
  user.to_s
end