Class: WikiPages::EventCreateService
- Inherits:
-
Object
- Object
- WikiPages::EventCreateService
- Defined in:
- app/services/wiki_pages/event_create_service.rb
Instance Method Summary collapse
- #execute(slug, page, action, event_fingerprint) ⇒ Object
-
#initialize(author) ⇒ EventCreateService
constructor
A new instance of EventCreateService.
Constructor Details
#initialize(author) ⇒ EventCreateService
Returns a new instance of EventCreateService.
6 7 8 9 10 |
# File 'app/services/wiki_pages/event_create_service.rb', line 6 def initialize() raise ArgumentError, 'author must not be nil' unless @author = end |
Instance Method Details
#execute(slug, page, action, event_fingerprint) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/services/wiki_pages/event_create_service.rb', line 12 def execute(slug, page, action, event_fingerprint) = WikiPage::Meta.find_or_create(slug, page) event = ::EventCreateService.new.wiki_event(, , action, event_fingerprint) ServiceResponse.success(payload: { event: event }) rescue ::EventCreateService::IllegalActionError, ::ActiveRecord::ActiveRecordError => e ServiceResponse.error(message: e., payload: { error: e }) end |