Class: Decidim::Components::ExportManifest
- Inherits:
-
Object
- Object
- Decidim::Components::ExportManifest
- Includes:
- ActiveModel::Model
- Defined in:
- lib/decidim/components/export_manifest.rb
Overview
This class serves as a DSL to declarative specify which artifacts are exportable in a component. It is used via the ‘ComponentManifest`.
Instance Attribute Summary collapse
-
#component_manifest ⇒ Object
readonly
Returns the value of attribute component_manifest.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#collection(&block) ⇒ Object
Public: Sets the collection when a block is given, or returns it if no block is provided.
-
#initialize(name, component_manifest) ⇒ ExportManifest
constructor
Initializes the manifest.
-
#serializer(serializer = nil) ⇒ Object
Public: Sets the serializer when an argument is provided, returns the stored serializer otherwise.
Constructor Details
#initialize(name, component_manifest) ⇒ ExportManifest
Initializes the manifest.
name - The name of the export artifact. It should be unique in the
component.
component_manifest - The parent ComponentManifest where this export
manifest belongs to.
26 27 28 29 |
# File 'lib/decidim/components/export_manifest.rb', line 26 def initialize(name, component_manifest) @name = name.to_sym @component_manifest = component_manifest end |
Instance Attribute Details
#component_manifest ⇒ Object (readonly)
Returns the value of attribute component_manifest.
12 13 14 |
# File 'lib/decidim/components/export_manifest.rb', line 12 def component_manifest @component_manifest end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/decidim/components/export_manifest.rb', line 12 def name @name end |
Instance Method Details
#collection(&block) ⇒ Object
Public: Sets the collection when a block is given, or returns it if no block is provided.
The collection will get passed an instance of ‘Decidim::Component` when it’s evaluated so you can easily find the elements to export.
&block - An optional block that returns the collection once evaluated.
Returns the stored collection.
40 41 42 43 44 45 46 |
# File 'lib/decidim/components/export_manifest.rb', line 40 def collection(&block) if block_given? @collection = block else @collection end end |
#serializer(serializer = nil) ⇒ Object
Public: Sets the serializer when an argument is provided, returns the stored serializer otherwise.
A ‘Serializer` will be run against each and every element of the collection in order to extract and process the relevant fields.
serializer - A subclass of ‘Decidim::Exporters::Serializer`.
Returns the stored serializer if previously stored, or ‘Decidim::Exporters::Serializer` as a default implementation.
58 59 60 |
# File 'lib/decidim/components/export_manifest.rb', line 58 def serializer(serializer = nil) @serializer ||= serializer || Decidim::Exporters::Serializer end |