Sha256: 8b18fcb6809220de9fab3f238433724f72d640d6a0422b077fc0b599f0fb26d9
Contents?: true
Size: 1.11 KB
Versions: 12
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Decidim module Admin class ImportExampleForm < Form attribute :name, String attribute :format, String validates :name, presence: true validates :format, presence: true validates :manifest, presence: true validates :reader_klass, presence: true validates :example_data, presence: true def example reader.example_file(example_data) end def available_formats Decidim::Admin::Import::Readers::ACCEPTED_MIME_TYPES end private def manifest @manifest ||= current_component.manifest.import_manifests.find do |import_manifest| import_manifest.name.to_s == name end end def example_data return unless manifest manifest.example(self, current_component) end def reader @reader ||= begin return unless reader_klass reader_klass.new("/dev/null") end end def reader_klass @reader_klass ||= Decidim::Admin::Import::Readers.search_by_file_extension(format) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems