Module: CommandPost::Identity

Defined in:
lib/command_post/identity/identity.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(aggregate_id) ⇒ Object



53
54
55
56
# File 'lib/command_post/identity/identity.rb', line 53

def self.find aggregate_id

  Aggregate.get_by_aggregate_id self, aggregate_id
end

.generate_checksum(value) ⇒ Object



25
26
27
28
29
# File 'lib/command_post/identity/identity.rb', line 25

def self.generate_checksum value 
  sha = Digest::SHA2.new
  sha.update(value)
  sha.to_s 
end

.select(&block) ⇒ Object



39
40
41
# File 'lib/command_post/identity/identity.rb', line 39

def self.select (&block) 
  Aggregate.where(self).select
end

Instance Method Details

#aggregate_idObject



13
14
15
16
# File 'lib/command_post/identity/identity.rb', line 13

def aggregate_id 

  @data[:aggregate_info][:aggregate_id]
end

#aggregate_infoObject



44
45
46
47
48
49
50
# File 'lib/command_post/identity/identity.rb', line 44

def aggregate_info
  if @data.keys.include? :aggregate_info
    @data[:aggregate_info]
  else
    raise "A request was made for 'AggregateInfo at a time when it was not present in object state."
  end
end

#aggregate_lookup_valueObject



8
9
10
11
# File 'lib/command_post/identity/identity.rb', line 8

def aggregate_lookup_value
  field = (schema_fields[:lookup][:use])
  (self.send field.to_sym).to_s
end

#aggregate_pointerObject



19
20
21
22
# File 'lib/command_post/identity/identity.rb', line 19

def aggregate_pointer

  AggregatePointer.new(aggregate_info)
end

#checksumObject



32
33
34
35
36
# File 'lib/command_post/identity/identity.rb', line 32

def checksum  
  data = Array.new
  @data.keys.select {|x| x != :aggregate_info}.each {|x| data <<  @data[x] }
  Identity.generate_checksum(data.join())
end