class Arpa::ProfilesController
Public Instance Methods
create()
click to toggle source
POST /profiles
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 25 def create profile_creator.create({ profile: profile_params }, success: redirect_to_index(I18n.t('flash.actions.create_profile.notice')), fail: render_errors(:new)) end
edit()
click to toggle source
GET /profiles/1/edit
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 20 def edit all_roles end
index()
click to toggle source
GET /profiles
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 6 def index @profiles = profile_finder.all end
new()
click to toggle source
GET /profiles/new
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 14 def new @profile = Arpa::Entities::Profile.new all_roles end
remove()
click to toggle source
DELETE /profiles/1
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 39 def remove profile_remover.remove({ profile: @profile }, success: redirect_to_index(I18n.t('flash.actions.remove_profile.notice')), fail: redirect_to_index(I18n.t('flash.actions.remove_profile.alert'))) end
show()
click to toggle source
GET /profiles/1
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 11 def show; end
update()
click to toggle source
PATCH/PUT /profiles/1
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 32 def update profile_updater.update({ profile: profile_params }, success: redirect_to_index(I18n.t('flash.actions.update_profile.notice')), fail: render_errors(:edit)) end
Private Instance Methods
all_roles()
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 82 def all_roles @roles = role_finder.all end
profile_creator()
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 62 def profile_creator @profile_creator ||= Arpa::Services::Profiles::ProfileManagerCreator.new end
profile_finder()
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 74 def profile_finder @profile_finder ||= Arpa::Repositories::Profiles::Finder.new end
profile_params()
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 90 def profile_params permitted_params = %i[id name description entity_id entity_class] params.require(:profile) .permit(permitted_params, role_ids: []) .to_h end
profile_remover()
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 70 def profile_remover @profile_remover ||= Arpa::Services::Profiles::ProfileManagerRemover.new end
profile_updater()
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 66 def profile_updater @profile_updater ||= Arpa::Services::Profiles::ProfileManagerUpdater.new end
redirect_to_index(message)
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 47 def redirect_to_index(message) lambda do |profile| redirect_to profile_path(profile.id), notice: message end end
render_errors(action_to_render)
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 53 def render_errors(action_to_render) lambda do |error| @profile = Arpa::Entities::Profile.new(profile_params) @error = error all_roles render action_to_render end end
role_finder()
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 78 def role_finder @role_finder ||= Arpa::Repositories::Roles::Finder.new end
set_profile()
click to toggle source
# File lib/generators/arpa/templates/controllers/profiles_controller.rb, line 86 def set_profile @profile = profile_finder.find(params[:id]) end