Class: Ecoportal::API::GraphQL::Base::Model

Inherits:
Common::Content::DoubleModel
  • Object
show all
Includes:
Common::GraphQL::ClassHelpers
Defined in:
lib/ecoportal/api/graphql/base/model.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.clientObject

Returns the value of attribute client.



9
10
11
# File 'lib/ecoportal/api/graphql/base/model.rb', line 9

def client
  @client
end

Class Method Details

.as_input(hash, clientMutationId: "") ⇒ Object



11
12
13
14
# File 'lib/ecoportal/api/graphql/base/model.rb', line 11

def as_input(hash, clientMutationId: "")
  hash_input = hash.merge(clientMutationId: clientMutationId)
  Ecoportal::API::Common::GraphQL::HashHelpers.remove_nil_keys_deep(hash_input, target: :id)
end

Instance Method Details

#as_input(clientMutationId: "") ⇒ Object



26
27
28
# File 'lib/ecoportal/api/graphql/base/model.rb', line 26

def as_input(clientMutationId: "")
  self.class.as_input(as_update(sym_keys: true), clientMutationId: clientMutationId)
end

#as_update(ref = :last, ignore: [], sym_keys: false) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/ecoportal/api/graphql/base/model.rb', line 17

def as_update(ref = :last, ignore: [], sym_keys: false)
  new_doc = as_json
  ref_doc = ref == :total ? initial_doc : original_doc
  Ecoportal::API::Common::HashDiff.diff(new_doc, ref_doc, ignore: ignore).yield_self do |out|
    next out unless sym_keys
    Ecoportal::API::Common::GraphQL::HashHelpers.keys_to_sym_deep(out)
  end
end