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.



8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
# File 'lib/models/porcelain.rb', line 8866

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.



8858
8859
8860
# File 'lib/models/porcelain.rb', line 8858

def description
  @description
end

#idObject

Unique identifier of the Policy.



8860
8861
8862
# File 'lib/models/porcelain.rb', line 8860

def id
  @id
end

#nameObject

Unique human-readable name of the Policy.



8862
8863
8864
# File 'lib/models/porcelain.rb', line 8862

def name
  @name
end

#policyObject

The content of the Policy, in Cedar policy language.



8864
8865
8866
# File 'lib/models/porcelain.rb', line 8864

def policy
  @policy
end

Instance Method Details

#to_json(options = {}) ⇒ Object



8878
8879
8880
8881
8882
8883
8884
# File 'lib/models/porcelain.rb', line 8878

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