module Conjur::Policy::Executor

Public Class Methods

class_for(action) click to toggle source
# File lib/conjur/policy/executor.rb, line 22
def class_for action
  if action.is_a?(Conjur::Policy::Types::Create)
    class_name = action.record.class.name.split("::")[-1]
    begin
      Conjur::Policy::Executor.const_get([ "Create", class_name ].join)
    rescue NameError
      Conjur::Policy::Executor::CreateRecord
    end
  else
    action_name = action.class.name.split("::")[-1]
    if action.respond_to?(:record)
      type_name = action.record.class.short_name
    end
    begin
      Conjur::Policy::Executor.const_get([ action_name, type_name ].compact.join)
    rescue NameError
      Conjur::Policy::Executor.const_get(action_name)
    end
  end
end