Class: ServiceFlow Abstract
- Inherits:
-
Object
- Object
- ServiceFlow
- Defined in:
- app/lib/service_flow.rb
Overview
Subclass and override #fetch_data and #copy_data to implement a custom ServiceFlow.
Direct Known Subclasses
ServiceFlows::Eventbrite::Event, ServiceFlows::Eventbrite::Events
Instance Attribute Summary collapse
-
#flow ⇒ Symbol
readonly
The flow that fetches, loads, and copies data.
-
#service ⇒ Service
readonly
The service that provides information such as the token.
Instance Method Summary collapse
-
#copy_data(opts = nil) ⇒ Boolean
Copy a subset of the saved ServiceFlowData somewhere else in JOGL.
-
#fetch_data(opts = nil) ⇒ ActiveRecord::Result?
Fetch and store the ServiceFlowData associated with the service flow.
-
#initialize(service) ⇒ ServiceFlow
constructor
A new instance of ServiceFlow.
-
#load_data ⇒ ServiceFlowData?
Load the saved ServiceFlowData data associated with the service flow.
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
#flow ⇒ Symbol (readonly)
Returns 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 |
#service ⇒ Service (readonly)
Returns 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.
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.
22 23 24 |
# File 'app/lib/service_flow.rb', line 22 def fetch_data(opts = nil) raise NotImplementedError end |
#load_data ⇒ ServiceFlowData?
Load the saved ServiceFlowData data associated with the service flow.
29 30 31 |
# File 'app/lib/service_flow.rb', line 29 def load_data ServiceFlowData.find_by(service_id: @service.id, flow: flow) end |