Class: PubSub::PayloadAttribute
- Inherits:
-
Object
- Object
- PubSub::PayloadAttribute
- Defined in:
- lib/pub_sub/payload_attribute.rb
Constant Summary collapse
- CannotEvaluate =
Class.new(StandardError)
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(attribute_name, explicit_payload, context) ⇒ PayloadAttribute
constructor
A new instance of PayloadAttribute.
Constructor Details
#initialize(attribute_name, explicit_payload, context) ⇒ PayloadAttribute
Returns a new instance of PayloadAttribute.
5 6 7 8 9 |
# File 'lib/pub_sub/payload_attribute.rb', line 5 def initialize(attribute_name, explicit_payload, context) @attribute_name = attribute_name @explicit_payload = explicit_payload @context = context end |
Instance Method Details
#get ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/pub_sub/payload_attribute.rb', line 11 def get return explicit_payload.fetch(attribute_name) if explicit_payload.key?(attribute_name) identifier? ? context.send(getter_name)&.id : context.send(getter_name) rescue NoMethodError raise CannotEvaluate, getter_name end |