Class: Apidae::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/apidae/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#apidae_userObject



7
8
9
# File 'app/controllers/apidae/application_controller.rb', line 7

def apidae_user
  send(Rails.application.config.apidae_user) if Rails.application.config.respond_to?(:apidae_user)
end

#check_user_data!Object



19
20
21
22
23
# File 'app/controllers/apidae/application_controller.rb', line 19

def check_user_data!
  unless user_has_data? || user_is_admin?
    redirect_to main_app.root_path, alert: "Il n'y a aucun projet Apidae associé à votre compte."
  end
end

#user_has_data?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/controllers/apidae/application_controller.rb', line 15

def user_has_data?
  apidae_user && apidae_user.respond_to?(:apidae_projects_ids) && !apidae_user.apidae_projects_ids.blank?
end

#user_is_admin?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/controllers/apidae/application_controller.rb', line 11

def user_is_admin?
  apidae_user && Rails.application.config.respond_to?(:apidae_admin) && Rails.application.config.apidae_admin.call(apidae_user)
end