Sha256: 308b81e2cb3df342864ce8c8b226038dcb1465bc1bb9a492bf4433c2a646e877

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

module Eco
  module API
    class SessionConfig
      class People < Hash

        def initialize(root:)
          super(nil)
          @root = root
        end

        def cache=(file)
          self["cache"] = file
        end

        def cache
          self["cache"]
        end

        # api queried logs
        def requests_folder=(folder)
          self["requests_folder"] = folder
        end

        def requests_folder
          self["requests_folder"]
        end

        # people to exclude from update feeds
        def discarded_file=(file)
          self["discarded_file"] = file
        end

        def discarded_file
          self["discarded_file"]
        end

        # internal-external fields map
        def fields_mapper=(file)
          self["fields_mapper"] = file
        end

        def fields_mapper
          self["fields_mapper"]
        end

        # person model
        def default_schema=(name)
          self["default_schema"] = name
        end

        def default_schema
          self["default_schema"]
        end

        def presets_custom=(file)
          self["presets_custom"] = file
        end

        def presets_custom
          self["presets_custom"]
        end

        def presets_map=(file)
          self["presets_map"] = file
        end

        def presets_map
          self["presets_map"]
        end

        # CUSTOM PERSON PARSERS
        def person_parser(format: :csv)
          self["parsers"] ||= Eco::API::Common::People::PersonParser.new
          new_parsers = Eco::API::Common::People::PersonParser.new

          yield(new_parsers, self)

          parsers = self["parsers"][format]
          self["parsers"][format] = parsers ? parsers.merge(new_parsers) : new_parsers
        end

        def parser(format: :csv)
          self.dig("parsers", format)
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eco-helpers-0.6.0 lib/eco/api/session_config/people.rb