Class: Lcms::Engine::MaterialBuildService

Inherits:
Object
  • Object
show all
Defined in:
app/services/lcms/engine/material_build_service.rb

Constant Summary collapse

EVENT_BUILT =
'material:built'
PDF_EXT_RE =
/\.pdf$/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials, opts = {}) ⇒ MaterialBuildService

Returns a new instance of MaterialBuildService.



14
15
16
17
18
# File 'app/services/lcms/engine/material_build_service.rb', line 14

def initialize(credentials, opts = {})
  @credentials = credentials
  @errors = []
  @options = opts
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



12
13
14
# File 'app/services/lcms/engine/material_build_service.rb', line 12

def errors
  @errors
end

Instance Method Details

#build(url) ⇒ Object



20
21
22
23
24
25
# File 'app/services/lcms/engine/material_build_service.rb', line 20

def build(url)
  @url = url
  result = pdf? ? build_from_pdf : build_from_gdoc
  ActiveSupport::Notifications.instrument EVENT_BUILT, id: result.id
  result
end