Class: Effective::CommitteeMember
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::CommitteeMember
- Defined in:
- app/models/effective/committee_member.rb
Instance Attribute Summary collapse
-
#committee_ids ⇒ Object
Returns the value of attribute committee_ids.
-
#user_ids ⇒ Object
Returns the value of attribute user_ids.
Instance Method Summary collapse
- #active?(date: nil) ⇒ Boolean
- #build_committee(attributes = {}) ⇒ Object
- #build_user(attributes = {}) ⇒ Object
- #email ⇒ Object
- #expired?(date: nil) ⇒ Boolean
- #to_s ⇒ Object
Instance Attribute Details
#committee_ids ⇒ Object
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_ids ⇒ Object
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
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 |
#email ⇒ Object
66 67 68 |
# File 'app/models/effective/committee_member.rb', line 66 def email user.try(:email) end |
#expired?(date: nil) ⇒ Boolean
79 80 81 |
# File 'app/models/effective/committee_member.rb', line 79 def expired?(date: nil) active?(date: date) == false end |
#to_s ⇒ Object
62 63 64 |
# File 'app/models/effective/committee_member.rb', line 62 def to_s user.to_s end |