Class: Para::Exporter::Base
- Defined in:
- lib/para/exporter/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/para/exporter/base.rb', line 4 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/para/exporter/base.rb', line 4 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/para/exporter/base.rb', line 4 def @options end |
Instance Method Details
#file ⇒ Object
18 19 20 |
# File 'lib/para/exporter/base.rb', line 18 def file @file ||= GlobalID::Locator.locate(store(:file_gid)) end |
#file_name ⇒ Object
22 23 24 |
# File 'lib/para/exporter/base.rb', line 22 def file_name @file_name ||= [name, extension].join end |
#perform(model_name: nil, **options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/para/exporter/base.rb', line 6 def perform(model_name: nil, **) @model = model_name && model_name.constantize @options = @name = model.try(:model_name).try(:route_key).try(:parameterize) # Render file and store it in a Library::File object, allowing us # to retrieve that file easily from the job and subsequent requests # file = Para::Library::File.create!(attachment: render) store(:file_gid, file.to_global_id) end |