Sha256: 310de349e9ca0ab7090f99b20193f601e7a510f817b37181154b67fa3aec52eb

Contents?: true

Size: 1.29 KB

Versions: 15

Compression:

Stored size: 1.29 KB

Contents

module Eco
  module API
    module Common
      module People
        class EntryFactory

          attr_reader :person_parser

          def initialize(schema:, person_parser: nil, fields_mapper: nil, logger: ::Logger.new(IO::NULL))
            raise "Constructor needs a PersonSchema. Given: #{schema}" if !schema.is_a?(Ecoportal::API::V1::PersonSchema)
            raise "Expecting PersonParser. Given: #{person_parser}" if person_parser && !person_parser.is_a?(Eco::API::Common::People::PersonParser)
            raise "Expecting Mapper object. Given: #{fields_mapper}" if fields_mapper && !fields_mapper.is_a?(Eco::Data::Mapper)

            @logger = logger
            @schema = Ecoportal::API::V1::PersonSchema.new(JSON.parse(schema.doc.to_json))

            default_parser = Eco::API::Common::People::DefaultParsers.new(schema: @schema)
            @parser = default_parser.merge(person_parser)

            @fields_mapper = fields_mapper
          end

          def new(data, dependencies: {})
            PersonEntry.new(data, parser: @parser, mapper: @fields_mapper, dependencies: dependencies, logger: @logger)
          end

          def entries(data)
            Entries.new(data, klass: PersonEntry, factory: self)
          end
        end

      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
eco-helpers-0.6.17 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.16 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.15 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.13 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.12 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.11 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.9 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.8 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.7 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.6 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.5 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.4 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.3 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.2 lib/eco/api/common/people/entry_factory.rb
eco-helpers-0.6.1 lib/eco/api/common/people/entry_factory.rb