Class: SDM::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

Policy is a collection of one or more statements that enforce fine-grained access control for the users of an organization.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description: nil, id: nil, name: nil, policy: nil) ⇒ Policy

Returns a new instance of Policy.



10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
# File 'lib/models/porcelain.rb', line 10449

def initialize(
  description: nil,
  id: nil,
  name: nil,
  policy: nil
)
  @description = description == nil ? "" : description
  @id = id == nil ? "" : id
  @name = name == nil ? "" : name
  @policy = policy == nil ? "" : policy
end

Instance Attribute Details

#descriptionObject

Optional description of the Policy.



10441
10442
10443
# File 'lib/models/porcelain.rb', line 10441

def description
  @description
end

#idObject

Unique identifier of the Policy.



10443
10444
10445
# File 'lib/models/porcelain.rb', line 10443

def id
  @id
end

#nameObject

Unique human-readable name of the Policy.



10445
10446
10447
# File 'lib/models/porcelain.rb', line 10445

def name
  @name
end

#policyObject

The content of the Policy, in Cedar policy language.



10447
10448
10449
# File 'lib/models/porcelain.rb', line 10447

def policy
  @policy
end

Instance Method Details

#to_json(options = {}) ⇒ Object



10461
10462
10463
10464
10465
10466
10467
# File 'lib/models/porcelain.rb', line 10461

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end