Class: RedisIPC::Channel::Event

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

Overview

Holds event params and the callback This also gives a container for calling said callback

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, &callback) ⇒ Event

Returns a new instance of Event.



169
170
171
172
173
174
# File 'lib/redis_ipc/channel.rb', line 169

def initialize(params, &callback)
  @params_layout = params
  @params = nil

  define_singleton_method(:execute_callback, &callback)
end

Instance Attribute Details

#group_nameObject (readonly)

Returns the value of attribute group_name.



167
168
169
# File 'lib/redis_ipc/channel.rb', line 167

def group_name
  @group_name
end

#instance_idObject (readonly)

Returns the value of attribute instance_id.



167
168
169
# File 'lib/redis_ipc/channel.rb', line 167

def instance_id
  @instance_id
end

#paramsObject (readonly)

Returns the value of attribute params.



167
168
169
# File 'lib/redis_ipc/channel.rb', line 167

def params
  @params
end

#source_groupObject (readonly)

Returns the value of attribute source_group.



167
168
169
# File 'lib/redis_ipc/channel.rb', line 167

def source_group
  @source_group
end

#stream_nameObject (readonly)

Returns the value of attribute stream_name.



167
168
169
# File 'lib/redis_ipc/channel.rb', line 167

def stream_name
  @stream_name
end

Instance Method Details

#execute(params:, stream_name:, group_name:, instance_id:, entry: nil) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/redis_ipc/channel.rb', line 176

def execute(params:, stream_name:, group_name:, instance_id:, entry: nil)
  @params = params.with_indifferent_access.slice(*@params_layout)
  @stream_name = stream_name
  @group_name = group_name
  @source_group = entry&.source_group
  @instance_id = instance_id

  execute_callback
ensure
  @params = nil
end