Class: ApplicationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/application_service.rb

Overview

must define object instance and object should respond to #errors method suitable for ActiveRecord instance as object

Direct Known Subclasses

AtPostBackService, FacebookLastStepService, ForitPostBackService, GoogleApiIndexV3Service, IaPostBackService, PackageLabelsService, PartnerService::Benchmark::CalculateService, PartnerService::Bills::CalculateService, PartnerService::Dashboards::CalculateService, PartnerService::Inventories::CapacityUtilizationService, PartnerService::Inventories::ChartService, PartnerService::Inventories::CreateService, PartnerService::Inventories::EditService, PartnerService::Inventories::GetInventoryWithTimeService, PartnerService::Inventories::SyncBookedSeatService, PartnerService::Inventories::UpdateService, PartnerService::LoyaltyChangeDetectorService, PartnerService::MenuSections::ExportMenuSectionsService, PartnerService::Ranking::CalculateService, PartnerService::ReportProgress, PartnerService::Reservations::Exports::ErrorHandler, PartnerService::Reservations::Exports::TrackingService, PartnerService::Reservations::MetricsService, PartnerService::Reservations::RestaurantSyncService, PartnerService::Reservations::SummarySync, PartnerService::Restaurant::Create, PartnerService::Restaurant::Update, PartnerService::Staff::ForgotPassword, PendingTransactionService, PhoneVerificationService, ReportService::Dashboard, RestaurantService::Create, RestaurantService::CreateBasic, RestaurantService::CreateFromApi, RestaurantService::TagAssignment, RestaurantService::UpdateInventory, RestaurantService::UpdateTags, ReviewService::Create, ReviewService::SecondHalfStep, ReviewService::SecondStep, StaffService::ForgotPassword, StaffService::TemporaryAccess, TicketGroupLabelsService, TicketService::Form, TicketService::OldForm, TicketService::Redeem, TicketService::Transaction, TimeEstimationService, VendorsService::GoogleReserve::DescriptionGeneratorService, VendorsService::GoogleReserve::PackageService, VoucherService::Apply, VoucherService::CreateTransaction, VoucherService::Modify, VoucherService::Validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#objectObject

Returns the value of attribute object.



8
9
10
# File 'app/services/application_service.rb', line 8

def object
  @object
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
# File 'app/services/application_service.rb', line 15

def execute
  execute!
rescue ActiveRecord::ActiveRecordError, ActiveRecord::RecordInvalid => error
  ServiceResult.new errors: object.errors, message: error.message
rescue => error
  APMErrorHandler.report 'Service operation failed', error: error
  error_msg = I18n.t('something_went_wrong')
  object.errors.add :base, error_msg
  ServiceResult.new message: error_msg, errors: object.errors
end

#execute!Object

have to return `ServiceResult` instance



11
12
13
# File 'app/services/application_service.rb', line 11

def execute!
  raise 'Not implemented error'
end