Class: PM::ObjectAttribute

Inherits:
PolicyElement show all
Defined in:
lib/policy_machine/policy_element.rb

Overview

An object attribute in a policy machine.

Direct Known Subclasses

Object

Instance Attribute Summary

Attributes inherited from PolicyElement

#extra_attributes, #policy_machine_uuid, #stored_pe, #unique_identifier

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PolicyElement

#==, #assign_to, #connected?, convert_stored_pe_to_pe, #delete, #initialize, #inspect, #method_missing, #respond_to_missing?, #unassign, #update

Constructor Details

This class inherits a constructor from PM::PolicyElement

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PM::PolicyElement

Class Method Details

.all(pm_storage_adapter, options = {}) ⇒ Object



196
197
198
199
200
# File 'lib/policy_machine/policy_element.rb', line 196

def self.all(pm_storage_adapter, options = {})
  pm_storage_adapter.find_all_of_type_object_attribute(options).map do |stored_pe|
    convert_stored_pe_to_pe(stored_pe, pm_storage_adapter, PM::ObjectAttribute)
  end
end

.create(unique_identifier, policy_machine_uuid, pm_storage_adapter, extra_attributes = {}) ⇒ Object



181
182
183
184
185
# File 'lib/policy_machine/policy_element.rb', line 181

def self.create(unique_identifier, policy_machine_uuid, pm_storage_adapter, extra_attributes = {})
  new_pe = new(unique_identifier, policy_machine_uuid, pm_storage_adapter, nil, extra_attributes)
  new_pe.stored_pe = pm_storage_adapter.add_object_attribute(unique_identifier, policy_machine_uuid, extra_attributes)
  new_pe
end

Instance Method Details

#policy_classesObject

Returns an array of policy classes in which this ObjectAttribute is included. Returns empty array if this ObjectAttribute is associated with no policy classes.



189
190
191
192
193
194
# File 'lib/policy_machine/policy_element.rb', line 189

def policy_classes
  pcs_for_object = @pm_storage_adapter.policy_classes_for_object_attribute(stored_pe)
  pcs_for_object.map do |stored_pc|
    self.class.convert_stored_pe_to_pe(stored_pc, @pm_storage_adapter, PM::PolicyClass)
  end
end