Class: MicroBunny::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/microbunny/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, settings = MicroBunny.settings) ⇒ Record

Returns a new instance of Record.



5
6
7
8
9
# File 'lib/microbunny/record.rb', line 5

def initialize(record, settings = MicroBunny.settings)
  @record = record
  @label = extract_label(record)
  @settings = settings
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



3
4
5
# File 'lib/microbunny/record.rb', line 3

def label
  @label
end

Instance Method Details

#addressObject



29
30
31
# File 'lib/microbunny/record.rb', line 29

def address
  "#{settings.consumer_app}-#{label}"
end

#idObject



11
12
13
14
15
16
17
18
19
# File 'lib/microbunny/record.rb', line 11

def id
  if string?
    record
  elsif active_record?
    record.id
  else
    raise_invalid_record
  end
end

#routing_key_for(event) ⇒ Object



25
26
27
# File 'lib/microbunny/record.rb', line 25

def routing_key_for(event)
  "#{event.name}.#{label}" 
end

#routing_key_matcherObject



21
22
23
# File 'lib/microbunny/record.rb', line 21

def routing_key_matcher
  "*.#{label}"
end