class PubSub::PayloadAttribute
Constants
- CannotEvaluate
Attributes
attribute_name[R]
context[R]
explicit_payload[R]
Public Class Methods
new(attribute_name, explicit_payload, context)
click to toggle source
# 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
Public Instance Methods
get()
click to toggle source
# 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
Private Instance Methods
getter_name()
click to toggle source
# File lib/pub_sub/payload_attribute.rb, line 27 def getter_name identifier? ? attribute_name.to_s.chomp('_id') : attribute_name end
identifier?()
click to toggle source
# File lib/pub_sub/payload_attribute.rb, line 23 def identifier? !context.respond_to?(attribute_name, true) && attribute_name.to_s.end_with?('_id') end