Sha256: e7982cda2fa279056d2708ef38ea6ab06361d555d0dda73d854bb0c3665ea288
Contents?: true
Size: 814 Bytes
Versions: 3
Compression:
Stored size: 814 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) return AuthorizationStatus.new(:ok) if can?(action_name.to_sym, 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
3 entries across 3 versions & 1 rubygems