lib/simple_segment/operations/operation.rb in simple_segment-0.3.0 vs lib/simple_segment/operations/operation.rb in simple_segment-1.0.0.pre
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module SimpleSegment
module Operations
class Operation
include SimpleSegment::Utils
@@ -8,30 +10,31 @@
name: 'simple_segment',
version: SimpleSegment::VERSION
}
}.freeze
- attr_reader :options, :request
-
def initialize(client, options = {})
@options = options
+ @context = DEFAULT_CONTEXT.merge(options[:context].to_h)
@request = Request.new(client)
end
def call
raise 'Must be implemented in a subclass'
end
private
+ attr_reader :options, :request, :context
+
def base_payload
check_identity!
current_time = Time.now
{
userId: options[:user_id],
anonymousId: options[:anonymous_id],
- context: DEFAULT_CONTEXT.merge(options[:context].to_h),
+ context: context,
integrations: options[:integrations],
timestamp: timestamp(options.fetch(:timestamp, current_time)),
sentAt: current_time.iso8601
}
end