Class: PGExaminer::Result::Table::Permission

Inherits:
Base
  • Object
show all
Defined in:
lib/pg_examiner/result/table.rb

Constant Summary collapse

CHARS_TO_LABELS =
{
  "r" => "SELECT", # "read"
  "w" => "UPDATE", # "write"
  "a" => "INSERT", # "append"
  "d" => "DELETE",
  "D" => "TRUNCATE",
  "x" => "REFERENCES",
  "t" => "TRIGGER",
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #diff, #diffable_attrs, #diffable_lists

Constructor Details

#initialize(acl) ⇒ Permission

Returns a new instance of Permission.



71
72
73
74
75
# File 'lib/pg_examiner/result/table.rb', line 71

def initialize(acl)
  @name, permissions = acl.split("=")
  permissions, @grantor = permissions.split("/")
  @permissions = permissions.split("").map{|char| CHARS_TO_LABELS.fetch(char)}
end

Instance Attribute Details

#grantorObject

Returns the value of attribute grantor.



59
60
61
# File 'lib/pg_examiner/result/table.rb', line 59

def grantor
  @grantor
end

#nameObject

Returns the value of attribute name.



59
60
61
# File 'lib/pg_examiner/result/table.rb', line 59

def name
  @name
end

#permissionsObject

Returns the value of attribute permissions.



59
60
61
# File 'lib/pg_examiner/result/table.rb', line 59

def permissions
  @permissions
end

Instance Method Details

#diffable_methodsObject



77
78
79
80
81
82
# File 'lib/pg_examiner/result/table.rb', line 77

def diffable_methods
  {
    "grantor"     => "grantor",
    "permissions" => "permissions",
  }
end