Class: MicroBunny::Record
- Inherits:
-
Object
- Object
- MicroBunny::Record
- Defined in:
- lib/microbunny/record.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #address ⇒ Object
- #id ⇒ Object
-
#initialize(record, settings = MicroBunny.settings) ⇒ Record
constructor
A new instance of Record.
- #routing_key_for(event) ⇒ Object
- #routing_key_matcher ⇒ Object
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
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'lib/microbunny/record.rb', line 3 def label @label end |
Instance Method Details
#address ⇒ Object
29 30 31 |
# File 'lib/microbunny/record.rb', line 29 def address "#{settings.consumer_app}-#{label}" end |
#id ⇒ Object
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_matcher ⇒ Object
21 22 23 |
# File 'lib/microbunny/record.rb', line 21 def routing_key_matcher "*.#{label}" end |