Sha256: 6deaf403e61b1010c497e357f82c91acd7cef03f85631ffc21a353709bc2a0e0

Contents?: true

Size: 766 Bytes

Versions: 5

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true

require "csv"

module Decidim
  module BulletinBoard
    module Graphql
      class FileAdapter
        attr_reader :file_name

        def initialize(file_name, _options = {}, &)
          @file_name = file_name
        end

        def execute(document:, operation_name: nil, variables: {}, context: {})
          body = {}
          body["query"] = document.to_query_string
          body["variables"] = variables if variables.any?
          body["operationName"] = operation_name if operation_name

          CSV.open(file_name, "a+", col_sep: ";") do |csv|
            csv << [JSON.generate(body), context[:headers]["Authorization"]]
          end

          { "data" => { "vote" => {} } }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-bulletin_board-0.24.4 lib/decidim/bulletin_board/graphql/file_adapter.rb
decidim-bulletin_board-0.24.3 lib/decidim/bulletin_board/graphql/file_adapter.rb
decidim-bulletin_board-0.24.2 lib/decidim/bulletin_board/graphql/file_adapter.rb
decidim-bulletin_board-0.24.1 lib/decidim/bulletin_board/graphql/file_adapter.rb
decidim-bulletin_board-0.24.0 lib/decidim/bulletin_board/graphql/file_adapter.rb