Sha256: 9266a65a126eb2e686cf35e743f98b55c56b3023a4a3da8517cc691a67419bf9
Contents?: true
Size: 871 Bytes
Versions: 7
Compression:
Stored size: 871 Bytes
Contents
# frozen_string_literal: true require "active_support/concern" module Decidim module Consultations module ActionAuthorization extend ActiveSupport::Concern included do helper_method :action_authorization end # Public: Returns the authorization object for an authorization. # # action_name - The action to authorize against. # # Returns an AuthorizationStatus def action_authorization(action_name, question = current_question) return AuthorizationStatus.new(:ok) if allowed_to?(action_name.to_sym, :question, question: question) AuthorizationStatus.new(:denied) end class AuthorizationStatus attr_reader :code def initialize(code) @code = code.to_sym end def ok? @code == :ok end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems