Class: Decidim::Maintenance::TaxonomyImporter
- Inherits:
-
Object
- Object
- Decidim::Maintenance::TaxonomyImporter
- Defined in:
- decidim-core/lib/decidim/maintenance/taxonomy_importer.rb
Instance Attribute Summary collapse
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#roots ⇒ Object
readonly
Returns the value of attribute roots.
Instance Method Summary collapse
- #import! ⇒ Object
-
#initialize(organization, roots) ⇒ TaxonomyImporter
constructor
A new instance of TaxonomyImporter.
Constructor Details
#initialize(organization, roots) ⇒ TaxonomyImporter
Returns a new instance of TaxonomyImporter.
6 7 8 9 10 |
# File 'decidim-core/lib/decidim/maintenance/taxonomy_importer.rb', line 6 def initialize(organization, roots) @organization = organization @roots = roots @result = { taxonomy_map: {}, taxonomies_created: [], taxonomies_assigned: {}, filters_created: {}, components_assigned: {}, failed_resources: [], failed_components: [] } end |
Instance Attribute Details
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
12 13 14 |
# File 'decidim-core/lib/decidim/maintenance/taxonomy_importer.rb', line 12 def organization @organization end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
12 13 14 |
# File 'decidim-core/lib/decidim/maintenance/taxonomy_importer.rb', line 12 def result @result end |
#roots ⇒ Object (readonly)
Returns the value of attribute roots.
12 13 14 |
# File 'decidim-core/lib/decidim/maintenance/taxonomy_importer.rb', line 12 def roots @roots end |
Instance Method Details
#import! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'decidim-core/lib/decidim/maintenance/taxonomy_importer.rb', line 14 def import!(&) roots.each do |name, element| root = find_taxonomy!(root_taxonomies, name) element["taxonomies"].each do |item_name, taxonomy| import_taxonomy_item(root, item_name, taxonomy) yield "Taxonomy imported", item_name if block_given? end element["filters"].each do |filter| import_filter(root, filter) yield "Filter imported", filter["name"] if block_given? end end end |