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.



12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
# File 'lib/models/porcelain.rb', line 12710

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.



12702
12703
12704
# File 'lib/models/porcelain.rb', line 12702

def description
  @description
end

#idObject

Unique identifier of the Policy.



12704
12705
12706
# File 'lib/models/porcelain.rb', line 12704

def id
  @id
end

#nameObject

Unique human-readable name of the Policy.



12706
12707
12708
# File 'lib/models/porcelain.rb', line 12706

def name
  @name
end

#policyObject

The content of the Policy, in Cedar policy language.



12708
12709
12710
# File 'lib/models/porcelain.rb', line 12708

def policy
  @policy
end

Instance Method Details

#to_json(options = {}) ⇒ Object



12722
12723
12724
12725
12726
12727
12728
# File 'lib/models/porcelain.rb', line 12722

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