Class: Ecoportal::API::GraphQL::Base::Page::DataField::People

Inherits:
DataField
  • Object
show all
Defined in:
lib/ecoportal/api/graphql/base/page/data_field/people.rb

Instance Method Summary collapse

Instance Method Details

#as_inputObject



37
38
39
40
41
# File 'lib/ecoportal/api/graphql/base/page/data_field/people.rb', line 37

def as_input
  return nil unless dirty?

  { people: { id: id, peopleIds: effective_people_ids } }
end

#dirty?Boolean

Dirty only when the effective people-id SET actually changed.

The read response can carry peopleIds: null while still populating the expanded people { id } (and cachedPeople) nodes (a partial / non-$content read). The default key-level leaf diff baselines on original_doc['peopleIds'] (null), so writing the SAME id set as already attached looks like a brand-new key and flags a change — a phantom-dirty update that sends peopleIds for a no-op. Compare id SETS (falling back to people[].id on both sides) instead. Mirrors CrossReference's references.nodes fallback / dirty? override for the identical disease.

Returns:

  • (Boolean)


33
34
35
# File 'lib/ecoportal/api/graphql/base/page/data_field/people.rb', line 33

def dirty?
  effective_people_ids.sort != people_ids_from(original_doc).sort
end

#people_idsObject



6
7
8
# File 'lib/ecoportal/api/graphql/base/page/data_field/people.rb', line 6

def people_ids
  people_ids_from(doc)
end

#people_ids=(ids) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/ecoportal/api/graphql/base/page/data_field/people.rb', line 10

def people_ids=(ids)
  # An explicit write makes `peopleIds` authoritative for THIS instance: without the
  # flag, a deliberate clear (`people_ids = []`) on a `peopleIds: null` baseline would
  # fall back to the `people` nodes on the doc side too, compare equal, and be silently
  # dropped. The flag confines the fallback to un-written docs.
  @people_ids_written  = true
  doc['peopleIds']     = Array(ids).compact
end

#value=(ids) ⇒ Object

v2 compat: scripts may set via people_ids= or direct assignment



20
21
22
# File 'lib/ecoportal/api/graphql/base/page/data_field/people.rb', line 20

def value=(ids)
  self.people_ids = ids
end