Class: Aggro::AggregateRef

Inherits:
Struct
  • Object
show all
Defined in:
lib/aggro/aggregate_ref.rb

Overview

Public: Reference to an Aggregate which may be local or remote.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



3
4
5
# File 'lib/aggro/aggregate_ref.rb', line 3

def id
  @id
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



3
4
5
# File 'lib/aggro/aggregate_ref.rb', line 3

def type
  @type
end

Instance Method Details

#command(command) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/aggro/aggregate_ref.rb', line 4

def command(command)
  response = send_command(command)

  if response.is_a? Message::InvalidTarget
    create
    response = send_command(command)
  end

  fail 'Could not send command' unless response.is_a? Message::OK

  self
end

#createObject



17
18
19
20
21
22
23
# File 'lib/aggro/aggregate_ref.rb', line 17

def create
  response = client.post build_create_message

  fail 'Could not create aggregate' unless response.is_a? Message::OK

  self
end

#query(query) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/aggro/aggregate_ref.rb', line 25

def query(query)
  response = send_query(query)

  if response.is_a? Message::InvalidTarget
    create
    response = send_query(query)
  end

  handle_query_response response
end