class Universities::Entity

Constants

ATTRIBUTES_MAPPING

Public Class Methods

build(hash) click to toggle source
# File lib/universities/entity.rb, line 27
def self.build(hash)
  new(**parse_attributes(hash))
end
new(web_pages: nil, alpha_two_code: nil, state_province: nil, country: nil, domains: nil, name: nil) click to toggle source
# File lib/universities/entity.rb, line 18
def initialize(web_pages: nil, alpha_two_code: nil, state_province: nil, country: nil, domains: nil, name: nil)
  @web_pages = web_pages
  @alpha_two_code = alpha_two_code
  @state_province = state_province
  @country = country
  @domains = domains
  @name = name
end
parse_attributes(hash) click to toggle source
# File lib/universities/entity.rb, line 31
def self.parse_attributes(hash)
  hash = hash.with_indifferent_access
  ATTRIBUTES_MAPPING.map do |attribute, hash_key|
    [attribute, hash.dig(hash_key)]
  end.to_h
end