Class: Decidim::Features::ExportManifest

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/features/export_manifest.rb

Overview

This class serves as a DSL to declarative specify which artifacts are exportable in a feature. It is used via the ‘FeatureManifest`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ExportManifest

Initializes the manifest.

name - The name of the export artifact. It should be unique in the

feature.


16
17
18
# File 'lib/decidim/features/export_manifest.rb', line 16

def initialize(name)
  @name = name.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/decidim/features/export_manifest.rb', line 9

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::Feature` 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.



29
30
31
32
33
34
35
# File 'lib/decidim/features/export_manifest.rb', line 29

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.



47
48
49
# File 'lib/decidim/features/export_manifest.rb', line 47

def serializer(serializer = nil)
  @serializer ||= serializer || Decidim::Exporters::Serializer
end