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.
-
#skip_fees ⇒ Object
Returns the value of attribute skip_fees.
-
#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
- #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
25 26 27 |
# File 'app/models/effective/registrar_action.rb', line 25 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.
32 33 34 |
# File 'app/models/effective/registrar_action.rb', line 32 def note_internal @note_internal end |
#note_to_buyer ⇒ Object
Returns the value of attribute note_to_buyer.
31 32 33 |
# File 'app/models/effective/registrar_action.rb', line 31 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.
30 31 32 |
# File 'app/models/effective/registrar_action.rb', line 30 def payment_card @payment_card end |
#payment_provider ⇒ Object
Mark Fees Paid - Order Attributes
29 30 31 |
# File 'app/models/effective/registrar_action.rb', line 29 def payment_provider @payment_provider end |
#skip_fees ⇒ Object
Returns the value of attribute skip_fees.
18 19 20 |
# File 'app/models/effective/registrar_action.rb', line 18 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
21 22 23 |
# File 'app/models/effective/registrar_action.rb', line 21 def status_ids @status_ids end |
Instance Method Details
#assign! ⇒ Object
76 77 78 79 |
# File 'app/models/effective/registrar_action.rb', line 76 def assign! update!(current_action: :assign) EffectiveMemberships.Registrar.assign!(owner, categories: categories, statuses: statuses, number: number) end |
#assign_attributes(atts) ⇒ Object
91 92 93 |
# File 'app/models/effective/registrar_action.rb', line 91 def assign_attributes(atts) super(atts.reject { |k, _| k.to_s.start_with?('status_remove_action_') }) end |
#categories ⇒ Object
119 120 121 |
# File 'app/models/effective/registrar_action.rb', line 119 def categories EffectiveMemberships.Category.where(id: @category_ids) if @category_ids.present? end |
#category ⇒ Object
115 116 117 |
# File 'app/models/effective/registrar_action.rb', line 115 def category EffectiveMemberships.Category.find(@category_id) if @category_id.present? end |
#fees_paid! ⇒ Object
81 82 83 84 |
# File 'app/models/effective/registrar_action.rb', line 81 def fees_paid! update!(current_action: :fees_paid) EffectiveMemberships.Registrar.fees_paid!(owner, order_attributes: order_attributes) end |
#number ⇒ Object
131 132 133 |
# File 'app/models/effective/registrar_action.rb', line 131 def number membership_number.presence end |
#order_attributes ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'app/models/effective/registrar_action.rb', line 135 def order_attributes { payment_provider: @payment_provider.presence, payment_card: @payment_card.presence, note_to_buyer: @note_to_buyer.presence, note_internal: @note_internal.presence }.compact end |
#reclassify! ⇒ Object
61 62 63 64 |
# File 'app/models/effective/registrar_action.rb', line 61 def reclassify! update!(current_action: :reclassify) EffectiveMemberships.Registrar.reclassify!(owner, to: category, skip_fees: skip_fees?) end |
#register! ⇒ Object
56 57 58 59 |
# File 'app/models/effective/registrar_action.rb', line 56 def register! update!(current_action: :register) EffectiveMemberships.Registrar.register!(owner, to: category, status: status, number: number, skip_fees: skip_fees?) end |
#remove! ⇒ Object
86 87 88 89 |
# File 'app/models/effective/registrar_action.rb', line 86 def remove! update!(current_action: :remove) EffectiveMemberships.Registrar.remove!(owner) end |
#save! ⇒ Object
99 100 101 |
# File 'app/models/effective/registrar_action.rb', line 99 def save! valid? ? true : raise('invalid') end |
#skip_fees? ⇒ Boolean
144 145 146 |
# File 'app/models/effective/registrar_action.rb', line 144 def skip_fees? EffectiveResources.truthy?(@skip_fees) end |
#status ⇒ Object
123 124 125 |
# File 'app/models/effective/registrar_action.rb', line 123 def status EffectiveMemberships.Status.find(@status_id) if @status_id.present? end |
#status_assign! ⇒ Object
66 67 68 69 |
# File 'app/models/effective/registrar_action.rb', line 66 def status_assign! update!(current_action: :status_assign) EffectiveMemberships.Registrar.status_assign!(owner, status: statuses) end |
#status_remove! ⇒ Object
71 72 73 74 |
# File 'app/models/effective/registrar_action.rb', line 71 def status_remove! update!(current_action: :status_remove) EffectiveMemberships.Registrar.status_remove!(owner, status: status) end |
#statuses ⇒ Object
127 128 129 |
# File 'app/models/effective/registrar_action.rb', line 127 def statuses EffectiveMemberships.Status.where(id: @status_ids) if @status_ids.present? end |
#to_s ⇒ Object
52 53 54 |
# File 'app/models/effective/registrar_action.rb', line 52 def to_s 'action' end |
#update!(atts) ⇒ Object
95 96 97 |
# File 'app/models/effective/registrar_action.rb', line 95 def update!(atts) assign_attributes(atts); save! end |