Class: PolicyMachineStorageAdapter::InMemory::PersistedPolicyElement

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

Overview

Class to represent policy elements

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unique_identifier, policy_machine_uuid, pe_type, extra_attributes) ⇒ PersistedPolicyElement

Ensure that attr keys are strings



246
247
248
249
250
251
252
253
254
255
# File 'lib/policy_machine_storage_adapters/in_memory.rb', line 246

def initialize(unique_identifier, policy_machine_uuid, pe_type, extra_attributes)
  @unique_identifier = unique_identifier
  @policy_machine_uuid = policy_machine_uuid
  @pe_type = pe_type
  @persisted = false
  @extra_attributes = extra_attributes
  extra_attributes.each do |key, value|
    define_singleton_method key, lambda {@extra_attributes[key]}
  end
end

Instance Attribute Details

#extra_attributesObject (readonly)

Returns the value of attribute extra_attributes.



243
244
245
# File 'lib/policy_machine_storage_adapters/in_memory.rb', line 243

def extra_attributes
  @extra_attributes
end

#pe_typeObject (readonly)

Returns the value of attribute pe_type.



243
244
245
# File 'lib/policy_machine_storage_adapters/in_memory.rb', line 243

def pe_type
  @pe_type
end

#persistedObject

Returns the value of attribute persisted.



242
243
244
# File 'lib/policy_machine_storage_adapters/in_memory.rb', line 242

def persisted
  @persisted
end

#policy_machine_uuidObject (readonly)

Returns the value of attribute policy_machine_uuid.



243
244
245
# File 'lib/policy_machine_storage_adapters/in_memory.rb', line 243

def policy_machine_uuid
  @policy_machine_uuid
end

#unique_identifierObject (readonly)

Returns the value of attribute unique_identifier.



243
244
245
# File 'lib/policy_machine_storage_adapters/in_memory.rb', line 243

def unique_identifier
  @unique_identifier
end

Instance Method Details

#==(other) ⇒ Object



257
258
259
260
261
262
# File 'lib/policy_machine_storage_adapters/in_memory.rb', line 257

def ==(other)
  return false unless other.is_a?(PersistedPolicyElement)
  self.unique_identifier == other.unique_identifier &&
    self.policy_machine_uuid == other.policy_machine_uuid &&
    self.pe_type == other.pe_type
end