Class: Mdm::Enrollment::Sync

Inherits:
Devices show all
Defined in:
lib/mdm/enrollment/service/sync.rb

Defined Under Namespace

Classes: DevicesCursorNotFound

Instance Method Summary collapse

Methods inherited from Devices

accepted_params, #method, #result, #start

Methods inherited from Mdm::Enrollment::Service::Base

accepted_params, #authenticate?, available_services, #method, #params, #params=, #result, #start

Instance Method Details

#cursorObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mdm/enrollment/service/sync.rb', line 14

def cursor
  @cursor ||=
    begin
      cursor = Mdm::Cursor.where(
        service: Mdm::Cursor::SYNC
      ).first || begin
                   # Create sync cursor based on Device service cursor
                   device_cursor = Cursor.where(
                     service: Cursor::DEVICES).first

                   # Raise if no device service cursor found
                   # Device service must be called first
                   if device_cursor.nil?
                     raise DevicesCursorNotFound
                   end

                   # Use device service cursor to create sync service cursor
                   Cursor.create(
                     service: Cursor::SYNC,
                     content: device_cursor.content)
                 end
      cursor
    end
end

#pathObject



10
11
12
# File 'lib/mdm/enrollment/service/sync.rb', line 10

def path
  '/devices/sync'
end