Class: Effective::RegistrarAction
- Inherits:
-
Object
- Object
- Effective::RegistrarAction
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/effective/registrar_action.rb
Instance Attribute Summary collapse
-
#category_id ⇒ Object
Reclassify & Register.
-
#category_ids ⇒ Object
Assign.
-
#current_action ⇒ Object
Returns the value of attribute current_action.
-
#current_user ⇒ Object
All Actions.
-
#membership_number ⇒ Object
Returns the value of attribute membership_number.
-
#note_internal ⇒ Object
Returns the value of attribute note_internal.
-
#note_to_buyer ⇒ Object
Returns the value of attribute note_to_buyer.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#owner_id ⇒ Object
Returns the value of attribute owner_id.
-
#owner_type ⇒ Object
Returns the value of attribute owner_type.
-
#payment_card ⇒ Object
Returns the value of attribute payment_card.
-
#payment_provider ⇒ Object
Mark Fees Paid - Order Attributes.
-
#purchased_at ⇒ Object
Returns the value of attribute purchased_at.
-
#skip_fees ⇒ Object
Reinstate.
-
#status_id ⇒ Object
Register.
-
#status_ids ⇒ Object
Status Change.
Instance Method Summary collapse
- #assign! ⇒ Object
- #assign_attributes(atts) ⇒ Object
- #categories ⇒ Object
- #category ⇒ Object
- #fees_paid! ⇒ Object
- #number ⇒ Object
- #order_attributes ⇒ Object
- #reclassify! ⇒ Object
- #register! ⇒ Object
- #reinstate! ⇒ Object
- #remove! ⇒ Object
- #save! ⇒ Object
- #skip_fees? ⇒ Boolean
- #status ⇒ Object
- #status_assign! ⇒ Object
- #status_remove! ⇒ Object
- #statuses ⇒ Object
- #to_s ⇒ Object
- #update!(atts) ⇒ Object
Instance Attribute Details
#category_id ⇒ Object
Reclassify & Register
16 17 18 |
# File 'app/models/effective/registrar_action.rb', line 16 def category_id @category_id end |
#category_ids ⇒ Object
Assign
28 29 30 |
# File 'app/models/effective/registrar_action.rb', line 28 def category_ids @category_ids end |
#current_action ⇒ Object
Returns the value of attribute current_action.
9 10 11 |
# File 'app/models/effective/registrar_action.rb', line 9 def current_action @current_action end |
#current_user ⇒ Object
All Actions
8 9 10 |
# File 'app/models/effective/registrar_action.rb', line 8 def current_user @current_user end |
#membership_number ⇒ Object
Returns the value of attribute membership_number.
17 18 19 |
# File 'app/models/effective/registrar_action.rb', line 17 def membership_number @membership_number end |
#note_internal ⇒ Object
Returns the value of attribute note_internal.
36 37 38 |
# File 'app/models/effective/registrar_action.rb', line 36 def note_internal @note_internal end |
#note_to_buyer ⇒ Object
Returns the value of attribute note_to_buyer.
35 36 37 |
# File 'app/models/effective/registrar_action.rb', line 35 def note_to_buyer @note_to_buyer end |
#owner ⇒ Object
Returns the value of attribute owner.
10 11 12 |
# File 'app/models/effective/registrar_action.rb', line 10 def owner @owner end |
#owner_id ⇒ Object
Returns the value of attribute owner_id.
10 11 12 |
# File 'app/models/effective/registrar_action.rb', line 10 def owner_id @owner_id end |
#owner_type ⇒ Object
Returns the value of attribute owner_type.
10 11 12 |
# File 'app/models/effective/registrar_action.rb', line 10 def owner_type @owner_type end |
#payment_card ⇒ Object
Returns the value of attribute payment_card.
33 34 35 |
# File 'app/models/effective/registrar_action.rb', line 33 def payment_card @payment_card end |
#payment_provider ⇒ Object
Mark Fees Paid - Order Attributes
32 33 34 |
# File 'app/models/effective/registrar_action.rb', line 32 def payment_provider @payment_provider end |
#purchased_at ⇒ Object
Returns the value of attribute purchased_at.
34 35 36 |
# File 'app/models/effective/registrar_action.rb', line 34 def purchased_at @purchased_at end |
#skip_fees ⇒ Object
Reinstate
21 22 23 |
# File 'app/models/effective/registrar_action.rb', line 21 def skip_fees @skip_fees end |
#status_id ⇒ Object
Register
13 14 15 |
# File 'app/models/effective/registrar_action.rb', line 13 def status_id @status_id end |
#status_ids ⇒ Object
Status Change
24 25 26 |
# File 'app/models/effective/registrar_action.rb', line 24 def status_ids @status_ids end |
Instance Method Details
#assign! ⇒ Object
85 86 87 88 |
# File 'app/models/effective/registrar_action.rb', line 85 def assign! update!(current_action: :assign) EffectiveMemberships.Registrar.assign!(owner, categories: categories, statuses: statuses, number: number) end |
#assign_attributes(atts) ⇒ Object
100 101 102 |
# File 'app/models/effective/registrar_action.rb', line 100 def assign_attributes(atts) super(atts.reject { |k, _| k.to_s.start_with?('status_remove_action_') }) end |
#categories ⇒ Object
128 129 130 |
# File 'app/models/effective/registrar_action.rb', line 128 def categories EffectiveMemberships.Category.where(id: @category_ids) if @category_ids.present? end |
#category ⇒ Object
124 125 126 |
# File 'app/models/effective/registrar_action.rb', line 124 def category EffectiveMemberships.Category.find(@category_id) if @category_id.present? end |
#fees_paid! ⇒ Object
90 91 92 93 |
# File 'app/models/effective/registrar_action.rb', line 90 def fees_paid! update!(current_action: :fees_paid) EffectiveMemberships.Registrar.fees_paid!(owner, order_attributes: order_attributes) end |
#number ⇒ Object
140 141 142 |
# File 'app/models/effective/registrar_action.rb', line 140 def number membership_number.presence end |
#order_attributes ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'app/models/effective/registrar_action.rb', line 144 def order_attributes { payment_provider: @payment_provider.presence, payment_card: @payment_card.presence, purchased_at: @purchased_at.presence, note_to_buyer: @note_to_buyer.presence, note_internal: @note_internal.presence }.compact end |
#reclassify! ⇒ Object
65 66 67 68 |
# File 'app/models/effective/registrar_action.rb', line 65 def reclassify! update!(current_action: :reclassify) EffectiveMemberships.Registrar.reclassify!(owner, to: category, number: number, skip_fees: skip_fees?) end |
#register! ⇒ Object
60 61 62 63 |
# File 'app/models/effective/registrar_action.rb', line 60 def register! update!(current_action: :register) EffectiveMemberships.Registrar.register!(owner, to: category, status: status, number: number, skip_fees: skip_fees?) end |
#reinstate! ⇒ Object
70 71 72 73 |
# File 'app/models/effective/registrar_action.rb', line 70 def reinstate! update!(current_action: :reinstate) EffectiveMemberships.Registrar.reinstate!(owner, number: number, skip_fees: skip_fees?) end |
#remove! ⇒ Object
95 96 97 98 |
# File 'app/models/effective/registrar_action.rb', line 95 def remove! update!(current_action: :remove) EffectiveMemberships.Registrar.remove!(owner, statuses: statuses) end |
#save! ⇒ Object
108 109 110 |
# File 'app/models/effective/registrar_action.rb', line 108 def save! valid? ? true : raise('invalid') end |
#skip_fees? ⇒ Boolean
154 155 156 |
# File 'app/models/effective/registrar_action.rb', line 154 def skip_fees? EffectiveResources.truthy?(@skip_fees) end |
#status ⇒ Object
132 133 134 |
# File 'app/models/effective/registrar_action.rb', line 132 def status EffectiveMemberships.Status.find(@status_id) if @status_id.present? end |
#status_assign! ⇒ Object
75 76 77 78 |
# File 'app/models/effective/registrar_action.rb', line 75 def status_assign! update!(current_action: :status_assign) EffectiveMemberships.Registrar.status_assign!(owner, status: statuses) end |
#status_remove! ⇒ Object
80 81 82 83 |
# File 'app/models/effective/registrar_action.rb', line 80 def status_remove! update!(current_action: :status_remove) EffectiveMemberships.Registrar.status_remove!(owner, status: status) end |
#statuses ⇒ Object
136 137 138 |
# File 'app/models/effective/registrar_action.rb', line 136 def statuses EffectiveMemberships.Status.where(id: @status_ids) if @status_ids.present? end |
#to_s ⇒ Object
56 57 58 |
# File 'app/models/effective/registrar_action.rb', line 56 def to_s 'action' end |
#update!(atts) ⇒ Object
104 105 106 |
# File 'app/models/effective/registrar_action.rb', line 104 def update!(atts) assign_attributes(atts); save! end |