Module: Conjur::Policy::Types::ActsAsResource

Included in:
Ruby::Policy, Group, Host, HostFactory, Layer, Policy, Resource, User, Variable, Webservice
Defined in:
lib/conjur/policy/types/records.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/conjur/policy/types/records.rb', line 16

def self.included(base)
  base.module_eval do
    attribute :id,   kind: :string, singular: true, dsl_accessor: true
    attribute :account, kind: :string, singular: true
    attribute :owner, kind: :role, singular: true, dsl_accessor: true
    
    attribute :annotations, kind: :hash, type: Hash, singular: true
    
    def description value
      annotation 'description', value
    end
    
    def annotation name, value
      self.annotations ||= {}
      self.annotations[name] = value
    end
  end
end

Instance Method Details

#actionObject



55
56
57
# File 'lib/conjur/policy/types/records.rb', line 55

def action
  :create
end

#immutable_attribute_namesObject



63
64
65
# File 'lib/conjur/policy/types/records.rb', line 63

def immutable_attribute_names
  []
end

#initialize(id = nil) ⇒ Object



35
36
37
# File 'lib/conjur/policy/types/records.rb', line 35

def initialize id = nil
  self.id = id if id
end

#resource?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/conjur/policy/types/records.rb', line 59

def resource?
  true
end

#resource_idObject



51
52
53
# File 'lib/conjur/policy/types/records.rb', line 51

def resource_id
  id
end

#resource_kindObject



47
48
49
# File 'lib/conjur/policy/types/records.rb', line 47

def resource_kind
  self.class.name.split("::")[-1].underscore
end

#resourceid(default_account = nil) ⇒ Object



43
44
45
# File 'lib/conjur/policy/types/records.rb', line 43

def resourceid  = nil
  [  || , resource_kind, id ].join(":")
end

#to_sObject



39
40
41
# File 'lib/conjur/policy/types/records.rb', line 39

def to_s
  "#{resource_kind.gsub('_', ' ')} '#{id}'#{ &&  != Conjur.configuration. ? ' in account \'' +  + '\'': ''}"
end