Class: OpenTox::Policy

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

Overview

single policy in a policies instance

Defined Under Namespace

Classes: Rule, Subject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Policy

Returns a new instance of Policy.



190
191
192
193
194
195
# File 'lib/policy.rb', line 190

def initialize(name)
  @name = name
  @rules = {}
  @subject_group = ""
  @subjects = {}
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



188
189
190
# File 'lib/policy.rb', line 188

def name
  @name
end

#rulesObject

Returns the value of attribute rules.



188
189
190
# File 'lib/policy.rb', line 188

def rules
  @rules
end

#subject_groupObject

Returns the value of attribute subject_group.



188
189
190
# File 'lib/policy.rb', line 188

def subject_group
  @subject_group
end

#subjectsObject

Returns the value of attribute subjects.



188
189
190
# File 'lib/policy.rb', line 188

def subjects
  @subjects
end

Instance Method Details

#new_rule(name, uri) ⇒ Object

create a new rule instance for the policy



198
199
200
# File 'lib/policy.rb', line 198

def new_rule(name, uri)
  @rules[name] = Rule.new(name, uri)
end

#new_subject(name, type, value) ⇒ Object

create a new subject instance for the policy



203
204
205
# File 'lib/policy.rb', line 203

def new_subject(name, type, value)
  @subjects[name] = Subject.new(name, type, value)
end

#urisArray

Returns set of uris affected by policy.

Returns:

  • (Array)

    set of uris affected by policy



208
209
210
# File 'lib/policy.rb', line 208

def uris
  @rules.collect{ |k,v| v.uri }.uniq
end