Sha256: ae5e75e263cdadf26a71081e49412c9ce1cb9e22b14880f74c4d50859880b803

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

Contents

class TestTrack::Remote::Identifier
  include TestTrack::RemoteModel

  collection_path '/api/v1/identifier'

  has_one :remote_visitor, data_key: :visitor, class_name: "TestTrack::Remote::Visitor"

  attributes :identifier_type, :visitor_id, :value

  validates :identifier_type, :visitor_id, :value, presence: true

  def fake_save_response_attributes
    { visitor: { id: visitor_id, assignments: [] } }
  end

  def visitor
    @visitor ||= TestTrack::Visitor.new(visitor_opts!)
  end

  private

  def visitor_opts!
    raise("Visitor data unavailable until you save this identifier.") unless attributes[:remote_visitor]

    { id: remote_visitor.id, assignments: remote_visitor.assignments }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
test_track_rails_client-4.0.0.alpha35 app/models/test_track/remote/identifier.rb
test_track_rails_client-4.0.0.alpha34 app/models/test_track/remote/identifier.rb