Class: Spree::Admin::PayoutProfilesController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Admin::PayoutProfilesController
- Defined in:
- app/controllers/spree/admin/payout_profiles_controller.rb
Instance Method Summary collapse
- #index ⇒ Object
- #load_types ⇒ Object
-
#location_after_save ⇒ Object
override.
-
#model_class ⇒ Object
override.
- #page ⇒ Object
- #per_page ⇒ Object
-
#permitted_resource_params ⇒ Object
override permit all attributes for now.
- #request_creator ⇒ Object
- #request_updater ⇒ Object
-
#reset_verification ⇒ Object
when updated, active must be false.
- #save_defaults! ⇒ Object
- #verify_with_bank ⇒ Object
Instance Method Details
#index ⇒ Object
58 59 60 61 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 58 def index @search = Spree::PayoutProfile.ransack(params[:q]) @payout_profiles = @search.result.page(page).per(per_page).order(default: :desc) end |
#load_types ⇒ Object
28 29 30 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 28 def load_types @types = ['Spree::PayoutProfiles::PaywayV2'] end |
#location_after_save ⇒ Object
override
64 65 66 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 64 def location_after_save edit_object_url(@object) end |
#model_class ⇒ Object
override
78 79 80 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 78 def model_class Spree::PayoutProfile end |
#page ⇒ Object
82 83 84 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 82 def page params[:page] || 1 end |
#per_page ⇒ Object
86 87 88 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 86 def per_page params[:per_page] || 12 end |
#permitted_resource_params ⇒ Object
override permit all attributes for now.
70 71 72 73 74 75 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 70 def permitted_resource_params key = ActiveModel::Naming.param_key(@object) permit_keys = params.require(key).keys params.require(key).permit(permit_keys) end |
#request_creator ⇒ Object
54 55 56 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 54 def request_creator ::Vpago::PayoutProfiles::Payway::PayoutProfileRequestCreator end |
#request_updater ⇒ Object
50 51 52 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 50 def request_updater ::Vpago::PayoutProfiles::Payway::PayoutProfileRequestUpdater end |
#reset_verification ⇒ Object
when updated, active must be false. call verify_with_bank to reactivate with bank.
16 17 18 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 16 def reset_verification @object.reset_verification! end |
#save_defaults! ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 20 def save_defaults! instance = Spree::PayoutProfile.find(@object.id) instance.default = Spree::Store.default.name == instance.name instance.set_default_preferences if instance.respond_to?(:set_default_preferences) instance.save! end |
#verify_with_bank ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/spree/admin/payout_profiles_controller.rb', line 32 def verify_with_bank @object = Spree::PayoutProfile.find(params[:id]) instance = if @object.registered_in_bank? request_updater.new(@object) else request_creator.new(@object) end if instance.call flash[:success] = (@object, :successfully_updated) else flash[:error] = instance..to_s end redirect_to edit_object_url(@object) end |