Class: Cumulus::S3::GrantDiff

Inherits:
Common::Diff show all
Includes:
GrantChange
Defined in:
lib/s3/models/GrantDiff.rb

Overview

Public: Represents a single difference between local configuration and an AWS Grant.

Constant Summary

Constants included from GrantChange

Cumulus::S3::GrantChange::PERMISSIONS

Constants included from Common::DiffChange

Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED

Instance Attribute Summary

Attributes inherited from Common::Diff

#aws, #changes, #info_only, #local, #type

Instance Method Summary collapse

Methods included from Common::DiffChange

next_change_id

Methods inherited from Common::Diff

#add_string, added, #local_name, modified, #to_s, unmanaged, #unmanaged_string

Constructor Details

#initialize(type, aws = nil, local = nil) ⇒ GrantDiff

Returns a new instance of GrantDiff.



19
20
21
22
23
24
25
26
27
28
# File 'lib/s3/models/GrantDiff.rb', line 19

def initialize(type, aws = nil, local = nil)
  super(type, aws, local)

  if aws and local
    @permissions = Common::ListChange.new(
      local.permissions - aws.permissions,
      aws.permissions - local.permissions
    )
  end
end

Instance Method Details

#asset_typeObject



30
31
32
# File 'lib/s3/models/GrantDiff.rb', line 30

def asset_type
  "Grant"
end

#aws_nameObject



34
35
36
# File 'lib/s3/models/GrantDiff.rb', line 34

def aws_name
  @aws.name
end

#diff_stringObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/s3/models/GrantDiff.rb', line 38

def diff_string
  case @type
  when PERMISSIONS
    [
      "#{@local.name}:",
      @permissions.removed.map { |p| Colors.removed("\t#{p}") },
      @permissions.added.map { |p| Colors.added("\t#{p}") },
    ].flatten.join("\n")
  end
end