Class: Conjur::Policy::Types::Policy

Inherits:
Record show all
Includes:
ActsAsResource, ActsAsRole
Defined in:
lib/conjur/policy/types/policy.rb

Overview

Policy includes the functionality of Entitlements, wrapped in a policy role, policy resource, policy id and policy version.

Instance Method Summary collapse

Methods included from ActsAsRole

#role?, #role_id, #role_kind, #roleid

Methods included from ActsAsResource

#action, #immutable_attribute_names, included, #initialize, #resource?, #resource_id, #resource_kind, #resourceid, #to_s

Methods inherited from Record

#resource?, #role?

Methods inherited from Base

#custom_attribute_names, #id_attribute, inherited, register_yaml_type, #resource?, #role?, short_name

Methods included from InheritableAttribute

inherit_for, #inheritable_attr

Methods included from TypeChecking

#expect_array, #expect_boolean, #expect_hash, #expect_integer, #expect_layer, #expect_member, #expect_permission, #expect_record, #expect_resource, #expect_role, #expect_string, #expect_type, #test_resource, #test_role

Methods included from AttributeDefinition

#attribute, #define_field, #define_plural_field, #field?, #yaml_field?, #yaml_field_type

Instance Method Details

#body(&block) ⇒ Object



153
154
155
156
157
158
# File 'lib/conjur/policy/types/policy.rb', line 153

def body &block
  if block_given?
    singleton :body, lambda { Body.new }, &block
  end
  @body
end

#body=(body) ⇒ Object



160
161
162
# File 'lib/conjur/policy/types/policy.rb', line 160

def body= body
  @body = body
end

#referenced_recordsObject

Body is handled specially.



149
150
151
# File 'lib/conjur/policy/types/policy.rb', line 149

def referenced_records
  super - Array(@body)
end

#resourceObject



141
142
143
144
145
146
# File 'lib/conjur/policy/types/policy.rb', line 141

def resource
  raise "account is nil" unless 
  @resource ||= Resource.new("#{}:policy:#{id}").tap do |resource|
    resource.owner = Role.new(role.roleid)
  end
end

#roleObject



134
135
136
137
138
139
# File 'lib/conjur/policy/types/policy.rb', line 134

def role
  raise "account is nil" unless 
  @role ||= Role.new("#{}:policy:#{id}").tap do |role|
    role.owner = Role.new(owner.roleid)
  end
end