Class: Lcms::Engine::DocumentBuildService
- Inherits:
-
Object
- Object
- Lcms::Engine::DocumentBuildService
- Defined in:
- app/services/lcms/engine/document_build_service.rb
Constant Summary collapse
- EVENT_BUILT =
'document:built'
Instance Method Summary collapse
-
#build_for(url, expand: false) ⇒ Object
Document ActiveRecord::Model.
-
#initialize(credentials, opts = {}) ⇒ DocumentBuildService
constructor
A new instance of DocumentBuildService.
Constructor Details
#initialize(credentials, opts = {}) ⇒ DocumentBuildService
Returns a new instance of DocumentBuildService.
10 11 12 13 |
# File 'app/services/lcms/engine/document_build_service.rb', line 10 def initialize(credentials, opts = {}) @credentials = credentials = opts end |
Instance Method Details
#build_for(url, expand: false) ⇒ Object
Returns Document ActiveRecord::Model.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/lcms/engine/document_build_service.rb', line 18 def build_for(url, expand: false) @content = download url = @template = DocTemplate::Template.parse @content create_document clear_preview_link content_key = foundational? ? :foundational_content : :original_content @document.update! content_key => content build @document.create_parts_for(template) ActiveSupport::Notifications.instrument EVENT_BUILT, id: document.id document.activate! document end |