Class: Conjur::Policy::CompactOutputResolver

Inherits:
Resolver show all
Defined in:
lib/conjur/policy/resolver.rb

Overview

Unsets attributes that make for more verbose YAML output. This class is used to compact YAML expectations in test cases. It expects pre-flattened input.

account attributes which match the provided account are set to nil. owner attributes which match the provided ownerid are removed.

Instance Attribute Summary

Attributes inherited from Resolver

#account, #namespace, #ownerid

Instance Method Summary collapse

Methods inherited from Resolver

#initialize, resolve

Constructor Details

This class inherits a constructor from Conjur::Policy::Resolver

Instance Method Details

#resolve(records) ⇒ Object



242
243
244
245
# File 'lib/conjur/policy/resolver.rb', line 242

def resolve records
  traverse records, Set.new, method(:resolve_owner)
  traverse records, Set.new, method(:resolve_account)
end

#resolve_account(record, visited) ⇒ Object



247
248
249
250
251
252
# File 'lib/conjur/policy/resolver.rb', line 247

def  record, visited
  if record.respond_to?(:account) && record.respond_to?(:account=) && record. && record. == self.
    record.remove_instance_variable :@account
  end
  traverse record.referenced_records, visited, method(:resolve_account)
end

#resolve_owner(record, visited) ⇒ Object



254
255
256
257
258
259
# File 'lib/conjur/policy/resolver.rb', line 254

def resolve_owner record, visited
  if record.respond_to?(:owner) && record.respond_to?(:owner=) && record.owner && record.owner.roleid == self.ownerid
    record.remove_instance_variable :@owner
  end
  traverse record.referenced_records, visited, method(:resolve_owner)
end