Class: EventStoreClient::DeserializedEvent
- Inherits:
 - 
      Object
      
        
- Object
 - EventStoreClient::DeserializedEvent
 
 
- Defined in:
 - lib/event_store_client/deserialized_event.rb
 
Constant Summary collapse
- LINK_TYPE =
 '$>'
Instance Attribute Summary collapse
- 
  
    
      #commit_position  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute commit_position.
 - 
  
    
      #custom_metadata  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute custom_metadata.
 - 
  
    
      #data  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute data.
 - 
  
    
      #id  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute id.
 - 
  
    
      #metadata  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute metadata.
 - 
  
    
      #prepare_position  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute prepare_position.
 - 
  
    
      #stream_name  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute stream_name.
 - 
  
    
      #stream_revision  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute stream_revision.
 - 
  
    
      #title  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute title.
 - 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute type.
 
Instance Method Summary collapse
- 
  
    
      #==(other)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Implements comparison of ‘EventStoreClient::DeserializedEvent`-s.
 - 
  
    
      #initialize(args = {})  ⇒ DeserializedEvent 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of DeserializedEvent.
 - 
  
    
      #link?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Detect whether an event is a link event.
 - 
  
    
      #payload_content_type  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
content type of the event data.
 - 
  
    
      #schema  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
event schema.
 - 
  
    
      #system?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Detect whether an event is a system event.
 - #to_h ⇒ Hash
 
Constructor Details
#initialize(args = {}) ⇒ DeserializedEvent
Returns a new instance of DeserializedEvent.
      26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 26 def initialize(args = {}) validate(args[:data]) unless args[:skip_validation] @data = args.fetch(:data) { {} } @type = args[:type] || self.class.name @metadata = args.fetch(:metadata) { {} }. merge( 'type' => @type, 'content-type' => payload_content_type ) @custom_metadata = args[:custom_metadata] || {} @stream_name = args[:stream_name] @stream_revision = args[:stream_revision] @prepare_position = args[:prepare_position] @commit_position = args[:commit_position] @title = args[:title] @id = args[:id] end  | 
  
Instance Attribute Details
#commit_position ⇒ Object (readonly)
Returns the value of attribute commit_position.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def commit_position @commit_position end  | 
  
#custom_metadata ⇒ Object (readonly)
Returns the value of attribute custom_metadata.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def @custom_metadata end  | 
  
#data ⇒ Object (readonly)
Returns the value of attribute data.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def data @data end  | 
  
#id ⇒ Object (readonly)
Returns the value of attribute id.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def id @id end  | 
  
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def @metadata end  | 
  
#prepare_position ⇒ Object (readonly)
Returns the value of attribute prepare_position.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def prepare_position @prepare_position end  | 
  
#stream_name ⇒ Object (readonly)
Returns the value of attribute stream_name.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def stream_name @stream_name end  | 
  
#stream_revision ⇒ Object (readonly)
Returns the value of attribute stream_revision.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def stream_revision @stream_revision end  | 
  
#title ⇒ Object (readonly)
Returns the value of attribute title.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def title @title end  | 
  
#type ⇒ Object (readonly)
Returns the value of attribute type.
      10 11 12  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 10 def type @type end  | 
  
Instance Method Details
#==(other) ⇒ Boolean
Implements comparison of ‘EventStoreClient::DeserializedEvent`-s. Two events matches if all of their attributes matches
      58 59 60 61 62  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 58 def ==(other) return false unless other.is_a?(EventStoreClient::DeserializedEvent) meaningful_attrs(to_h) == meaningful_attrs(other.to_h) end  | 
  
#link? ⇒ Boolean
Detect whether an event is a link event
      75 76 77  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 75 def link? type == LINK_TYPE end  | 
  
#payload_content_type ⇒ Object
content type of the event data
      50 51 52  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 50 def payload_content_type 'application/json' end  | 
  
#schema ⇒ Object
event schema
      47  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 47 def schema; end  | 
  
#system? ⇒ Boolean
Detect whether an event is a system event
      81 82 83 84 85  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 81 def system? return false unless type type.start_with?('$') end  | 
  
#to_h ⇒ Hash
      65 66 67 68 69 70 71  | 
    
      # File 'lib/event_store_client/deserialized_event.rb', line 65 def to_h instance_variables.each_with_object({}) do |var, result| key = var.to_s key[0] = '' # remove @ sign result[key.to_sym] = instance_variable_get(var) end end  |