Class: Ecoportal::API::GraphQL::Base::Page::DataField::ContractorEntities
- Inherits:
-
DataField
- Object
- DataField
- Ecoportal::API::GraphQL::Base::Page::DataField::ContractorEntities
- Defined in:
- lib/ecoportal/api/graphql/base/page/data_field/contractor_entities.rb
Overview
Contractor entity selector field. Stores references to ContractorEntity records.
Instance Method Summary collapse
- #as_input ⇒ Object
-
#contractor_entity_ids ⇒ Object
Current contractor-entity ids.
- #contractor_entity_ids=(ids) ⇒ Object
-
#dirty? ⇒ Boolean
Dirty only when the effective id SET actually changed — same phantom-dirty class as CrossReference (READ one key, WRITE another): the default leaf diff flags the field the moment the
contractorskey appears, even for a no-op restatement or a clear on an already-empty field. -
#value=(ids) ⇒ Object
v2 compat alias.
Instance Method Details
#as_input ⇒ Object
32 33 34 35 36 |
# File 'lib/ecoportal/api/graphql/base/page/data_field/contractor_entities.rb', line 32 def as_input return nil unless dirty? { contractorEntities: { id: id, contractorEntityIds: contractor_entity_ids } } end |
#contractor_entity_ids ⇒ Object
Current contractor-entity ids. The GraphQL response carries them under
contractorEntities (CommonPageUnion's contractorEntitiesField), NOT contractors
— so read from there. After a contractor_entity_ids= write, prefer the staged value.
11 12 13 |
# File 'lib/ecoportal/api/graphql/base/page/data_field/contractor_entities.rb', line 11 def contractor_entity_ids contractor_ids_from(doc) end |
#contractor_entity_ids=(ids) ⇒ Object
15 16 17 |
# File 'lib/ecoportal/api/graphql/base/page/data_field/contractor_entities.rb', line 15 def contractor_entity_ids=(ids) doc['contractors'] = Array(ids).map { |id_val| { 'id' => id_val } } end |
#dirty? ⇒ Boolean
Dirty only when the effective id SET actually changed — same phantom-dirty class as
CrossReference (READ one key, WRITE another): the default leaf diff flags the field
the moment the contractors key appears, even for a no-op restatement or a clear on
an already-empty field.
28 29 30 |
# File 'lib/ecoportal/api/graphql/base/page/data_field/contractor_entities.rb', line 28 def dirty? contractor_ids_from(doc).sort != contractor_ids_from(original_doc).sort end |
#value=(ids) ⇒ Object
v2 compat alias
20 21 22 |
# File 'lib/ecoportal/api/graphql/base/page/data_field/contractor_entities.rb', line 20 def value=(ids) self.contractor_entity_ids = ids end |