Class: Effective::MembershipHistory

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

Instance Method Summary collapse

Instance Method Details

#end_periodObject



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

def end_period
  EffectiveMemberships.Registrar.period(date: end_on)
end

#membership_categoriesObject

These two accessors are for the memberships history form. But we just assign categories and category_ids directly in registrar.



49
50
51
# File 'app/models/effective/membership_history.rb', line 49

def membership_categories
  category_ids.present? ? EffectiveMemberships.Category.where(id: category_ids) : []
end

#membership_category_idsObject



57
58
59
# File 'app/models/effective/membership_history.rb', line 57

def membership_category_ids
  membership_categories.map(&:id)
end

#membership_category_ids=(ids) ⇒ Object



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

def membership_category_ids=(ids)
  categories = EffectiveMemberships.Category.where(id: ids)
  assign_attributes(categories: categories.map(&:to_s), category_ids: categories.map(&:id))
end

#membership_status_idsObject



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

def membership_status_ids
  membership_statuses.map(&:id)
end

#membership_status_ids=(ids) ⇒ Object



70
71
72
73
# File 'app/models/effective/membership_history.rb', line 70

def membership_status_ids=(ids)
  statuses = EffectiveMemberships.Status.where(id: ids)
  assign_attributes(statuses: statuses.map(&:to_s), status_ids: statuses.map(&:id))
end

#membership_statusesObject



53
54
55
# File 'app/models/effective/membership_history.rb', line 53

def membership_statuses
  status_ids.present? ? EffectiveMemberships.Status.where(id: status_ids) : []
end

#start_periodObject



75
76
77
# File 'app/models/effective/membership_history.rb', line 75

def start_period
  EffectiveMemberships.Registrar.period(date: start_on)
end

#to_sObject



43
44
45
# File 'app/models/effective/membership_history.rb', line 43

def to_s
  model_name.human
end