Class: Aggro::Channel

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

Overview

Private: Provides an interface to communicate with an aggregate or saga.

Only loads the target object when needed.

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



4
5
6
# File 'lib/aggro/channel.rb', line 4

def id
  @id
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



4
5
6
# File 'lib/aggro/channel.rb', line 4

def type
  @type
end

Instance Method Details

#forward_command(command) ⇒ Object



5
6
7
# File 'lib/aggro/channel.rb', line 5

def forward_command(command)
  target << command if handles_command?(command)
end

#handles_command?(command) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/aggro/channel.rb', line 9

def handles_command?(command)
  target_class.allows? command
end

#handles_query?(query) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/aggro/channel.rb', line 13

def handles_query?(query)
  target_class.responds_to? query
end

#run_query(query) ⇒ Object



17
18
19
# File 'lib/aggro/channel.rb', line 17

def run_query(query)
  target.ask query if handles_query? query
end