Class: Roseflow::LinkedIn::Person::Object

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/roseflow/linkedin/person/object.rb

Defined Under Namespace

Classes: PersonContract, PersonMapper

Class Method Summary collapse

Class Method Details

.new(input) ⇒ Object

Raises:

  • (ArgumentError)


59
60
61
62
63
64
65
# File 'lib/roseflow/linkedin/person/object.rb', line 59

def self.new(input)
  experiences = input.delete("experiences")
  input[:experiences] = experiences.map { |experience| Experience.new(experience) } if experiences
  validation = self.contract_object.new.call(input)
  raise ArgumentError, validation.errors.to_h.inspect unless validation.success?
  super(validation.to_h)
end