Module: Ecoportal::API::Common::GraphQL::Model::AsInput

Included in:
Ecoportal::API::Common::GraphQL::Model
Defined in:
lib/ecoportal/api/common/graphql/model/as_input.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



18
19
20
21
22
23
# File 'lib/ecoportal/api/common/graphql/model/as_input.rb', line 18

def included(base)
  super

  base.send(:include, Model::Diffable)
  base.extend ClassMethods
end

Instance Method Details

#as_input(target_class: nil, clientMutationId: '') ⇒ Object

INSTANCE METHODS



40
41
42
43
44
45
46
47
48
# File 'lib/ecoportal/api/common/graphql/model/as_input.rb', line 40

def as_input(target_class: nil, clientMutationId: '')
  return target_class.from_model(self, client_mutation_id: clientMutationId) if target_class

  diff = as_update
  return nil if diff.nil?

  diff[:patchVer] = patchVer if respond_to?(:patchVer) && !patchVer.nil?
  self.class.as_input(diff, clientMutationId: clientMutationId)
end