Sha256: 617a7581b541543d313aef816720691fb104dde6d4a41976c319e9e251a47854

Contents?: true

Size: 770 Bytes

Versions: 2

Compression:

Stored size: 770 Bytes

Contents

module RocketJobMissionControl
  class ApplicationController < ActionController::Base
    protect_from_forgery with: :exception

    around_action :with_time_zone

    private

    def with_time_zone(&block)
      if time_zone = session["time_zone"] || "UTC"
        Time.use_zone(time_zone, &block)
      end
    end

    def current_policy
      @current_policy ||= begin
        @args =
          if Config.authorization_callback
            instance_exec(&Config.authorization_callback)
          else
            {roles: %i[admin]}
          end
        AccessPolicy.new(Authorization.new(**@args))
      end
    end

    def login
      @login ||= begin
        args = instance_exec(&Config.authorization_callback)
        args[:login]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rocketjob_mission_control-6.0.0.beta app/controllers/rocket_job_mission_control/application_controller.rb
rocketjob_mission_control-5.0.1 app/controllers/rocket_job_mission_control/application_controller.rb