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.



8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
# File 'lib/models/porcelain.rb', line 8619

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.



8611
8612
8613
# File 'lib/models/porcelain.rb', line 8611

def description
  @description
end

#idObject

Unique identifier of the Policy.



8613
8614
8615
# File 'lib/models/porcelain.rb', line 8613

def id
  @id
end

#nameObject

Unique human-readable name of the Policy.



8615
8616
8617
# File 'lib/models/porcelain.rb', line 8615

def name
  @name
end

#policyObject

The content of the Policy, in Cedar policy language.



8617
8618
8619
# File 'lib/models/porcelain.rb', line 8617

def policy
  @policy
end

Instance Method Details

#to_json(options = {}) ⇒ Object



8631
8632
8633
8634
8635
8636
8637
# File 'lib/models/porcelain.rb', line 8631

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