class NoSE::Serialize::EntityBuilder

Reconstruct the fields of an entity

Public Instance Methods

call(_, fragment:, user_options:, **) click to toggle source
# File lib/nose/serialize.rb, line 188
def call(_, fragment:, user_options:, **)
  # Pull the field from the map of all entities
  entity_map = user_options[:entity_map]
  entity = entity_map[fragment['name']]

  # Add all fields from the entity
  fields = EntityFieldRepresenter.represent([])
  fields = fields.from_hash fragment['fields'],
                            user_options: { entity_map: entity_map }
  fields.each { |field| entity.send(:<<, field, freeze: false) }

  entity
end