Class: ServiceFlow Abstract

Inherits:
Object
  • Object
show all
Defined in:
app/lib/service_flow.rb

Overview

This class is abstract.

Subclass and override #fetch_data and #copy_data to implement a custom ServiceFlow.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ ServiceFlow

Returns a new instance of ServiceFlow.



13
14
15
16
# File 'app/lib/service_flow.rb', line 13

def initialize(service)
  @flow = self.class.name.demodulize.downcase.to_sym
  @service = service
end

Instance Attribute Details

#flowSymbol (readonly)

Returns the flow that fetches, loads, and copies data.

Returns:

  • (Symbol)

    the flow that fetches, loads, and copies data



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/lib/service_flow.rb', line 10

class ServiceFlow
  attr_reader :flow, :service

  def initialize(service)
    @flow = self.class.name.demodulize.downcase.to_sym
    @service = service
  end

  # Fetch and store the ServiceFlowData associated with the service flow.
  # E.g., fetch events from Eventbrite and store them in service_flow_data.
  #
  # @return [ActiveRecord::Result, nil] the service flow data.
  def fetch_data(opts = nil)
    raise NotImplementedError
  end

  # Load the saved ServiceFlowData data associated with the service flow.
  #
  # @return [ServiceFlowData, nil] the service flow data.
  def load_data
    ServiceFlowData.find_by(service_id: @service.id, flow: flow)
  end

  # Copy a subset of the saved ServiceFlowData somewhere else in JOGL.
  # E.g., copy Eventbrite events from service_flow_data into Activities.
  #
  # @return [Boolean] whether or not the copy was successful.
  def copy_data(opts = nil)
    raise NotImplementedError
  end
end

#serviceService (readonly)

Returns the service that provides information such as the token.

Returns:

  • (Service)

    the service that provides information such as the token



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/lib/service_flow.rb', line 10

class ServiceFlow
  attr_reader :flow, :service

  def initialize(service)
    @flow = self.class.name.demodulize.downcase.to_sym
    @service = service
  end

  # Fetch and store the ServiceFlowData associated with the service flow.
  # E.g., fetch events from Eventbrite and store them in service_flow_data.
  #
  # @return [ActiveRecord::Result, nil] the service flow data.
  def fetch_data(opts = nil)
    raise NotImplementedError
  end

  # Load the saved ServiceFlowData data associated with the service flow.
  #
  # @return [ServiceFlowData, nil] the service flow data.
  def load_data
    ServiceFlowData.find_by(service_id: @service.id, flow: flow)
  end

  # Copy a subset of the saved ServiceFlowData somewhere else in JOGL.
  # E.g., copy Eventbrite events from service_flow_data into Activities.
  #
  # @return [Boolean] whether or not the copy was successful.
  def copy_data(opts = nil)
    raise NotImplementedError
  end
end

Instance Method Details

#copy_data(opts = nil) ⇒ Boolean

Copy a subset of the saved ServiceFlowData somewhere else in JOGL. E.g., copy Eventbrite events from service_flow_data into Activities.

Returns:

  • (Boolean)

    whether or not the copy was successful.

Raises:

  • (NotImplementedError)


37
38
39
# File 'app/lib/service_flow.rb', line 37

def copy_data(opts = nil)
  raise NotImplementedError
end

#fetch_data(opts = nil) ⇒ ActiveRecord::Result?

Fetch and store the ServiceFlowData associated with the service flow. E.g., fetch events from Eventbrite and store them in service_flow_data.

Returns:

  • (ActiveRecord::Result, nil)

    the service flow data.

Raises:

  • (NotImplementedError)


22
23
24
# File 'app/lib/service_flow.rb', line 22

def fetch_data(opts = nil)
  raise NotImplementedError
end

#load_dataServiceFlowData?

Load the saved ServiceFlowData data associated with the service flow.

Returns:



29
30
31
# File 'app/lib/service_flow.rb', line 29

def load_data
  ServiceFlowData.find_by(service_id: @service.id, flow: flow)
end