Sha256: fb9131a8f27e3a6fb40f28ab7fc0f4f91442f975a909d80629c3d86ecf350928

Contents?: true

Size: 1.56 KB

Versions: 36

Compression:

Stored size: 1.56 KB

Contents

module Eco
  module API
    module Common
      module People

        # Class to define a set of default attribute parsers
        class DefaultParsers < PersonParser

          def initialize(*args)
            super(*args)
            define_defaults
          end

          private

          def define_defaults
            # Select Options
            select_hashes = @schema.fields.map do |fld|
              if fld.type == "select"
                raise "The schema selection field '#{fld.name}' is missing selection options." unless fld.options && !fld.options.empty?
                options_hash = fld.options.map { |v| [v.downcase.strip, v] }.to_h
                [fld.alt_id, options_hash]
              end
            end.compact.to_h

            SelectParser.new(self, select_hashes: select_hashes).process
            BooleanParser.new(self).process
            NumericParser.new(self).process
            DateParser.new(self).process
            MultiParser.new(self).process

            # ALWAYS PRESENT FIELDS
            SendInvitesParser.new(self).process

            # FORMAT PARSER
            CSVParser.new(self).process
          end

        end
      end
    end
  end
end

require_relative 'default_parsers/select_parser'
require_relative 'default_parsers/boolean_parser'
require_relative 'default_parsers/numeric_parser'
require_relative 'default_parsers/date_parser'
require_relative 'default_parsers/multi_parser'
require_relative 'default_parsers/send_invites_parser'
require_relative 'default_parsers/csv_parser'

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
eco-helpers-1.5.0 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.4.2 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.19 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.4.1 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.4.0 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.18 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.17 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.16 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.15 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.14 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.13 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.12 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.11 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.10 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.9 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.8 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.7 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.6 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.5 lib/eco/api/common/people/default_parsers.rb
eco-helpers-1.3.4 lib/eco/api/common/people/default_parsers.rb