Class: Redox::Query

Inherits:
Models::Message show all
Defined in:
lib/redox/query.rb

Instance Attribute Summary

Attributes inherited from Models::Message

#_body

Instance Method Summary collapse

Methods inherited from Model

from_redox_json, #initialize, redox_property, #to_redox_hash, #to_redox_json, to_snake_case, #value_to_redox_hash

Constructor Details

This class inherits a constructor from Redox::Model

Instance Method Details

#perform(source, destination_id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/redox/query.rb', line 7

def perform(source, destination_id)
  data_model, event_type = self.class.name.split("::").drop(1)
  self.meta = {
    data_model: data_model,
    event_type: event_type,
    event_date_time: DateTime.now.iso8601,
    destinations: [Redox::Models::Destination.new(id: destination_id)]
  }
  result_body = source.execute_query self
  response = response_type.from_redox_json result_body
  response._body = result_body
  response
end