Sha256: faeb97fd1fbd4083f582640564e6812f71346f331a36c37cbf94a5960e03f792
Contents?: true
Size: 1.21 KB
Versions: 9
Compression:
Stored size: 1.21 KB
Contents
module Actions module Middleware # Helpers for remote actions # wraps the plan/run/finalize methods to include the info about the user # that triggered the action. class RemoteAction < Dynflow::Middleware def plan(*args) fail "No current user is set. Please set User.current to perform a remote action" if User.current.nil? pass(*args).tap do action.input[:remote_user] = User.remote_user action.input[:remote_cp_user] = User.remote_user end end def run(*args) as_remote_user { pass(*args) } end def finalize as_remote_user { pass } end private def as_cp_user(&block) fail 'missing :remote_user' unless cp_user ::User.cp_config('cp-user' => cp_user, &block) end def as_pulp_user(&block) fail 'missing :remote_user' unless remote_user User.pulp_config(remote_user, &block) end def remote_user action.input[:remote_user] end def cp_user action.input[:remote_cp_user] end def as_remote_user as_cp_user do as_pulp_user do yield end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems