Class: Ecoportal::API::GraphQL::Base::LocationStructure::Draft

Inherits:
Logic::BaseModel show all
Includes:
Error::LocationsError::FetchNested
Defined in:
lib/ecoportal/api/graphql/base/location_structure/draft.rb,
lib/ecoportal/api/graphql/base/location_structure/draft/structure.rb

Direct Known Subclasses

Model::LocationStructure::Draft

Defined Under Namespace

Classes: Structure

Constant Summary

Constants included from Common::GraphQL::Model::Diffable

Common::GraphQL::Model::Diffable::DIFF_CLASS

Instance Method Summary collapse

Methods included from Error::LocationsError::FetchNested

#conflictingIds, #locations_error?, #locations_error_doc, #validationErrors, #validationErrors?

Methods included from Common::GraphQL::Model::AsInput

#as_input

Methods included from Common::GraphQL::Model::Diffable

#as_update, #dirty?

Instance Method Details

#conflictingIds?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 78

def conflictingIds?
  (conflictingIds || []).any?
end

#error?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 28

def error?
  !ok?               ||
    result_errors?   ||
    conflictingIds?
end

#error_docObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 34

def error_doc
  if result_errors?
    {
      results: [result_errors.first&.error_doc]
    }
  elsif conflictingIds?
    {
      conflictingIds: conflictingIds.doc
    }
  elsif !ok?
    {
      ok: false
    }
  end
end

#parent_structureObject

Note:

draft is in a collection of drafts



63
64
65
66
67
68
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 63

def parent_structure
  return unless _parent != self
  return unless _parent._parent != _parent

  _parent._parent
end

#result_errorsObject



74
75
76
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 74

def result_errors
  results.select(&:error?)
end

#result_errors?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 70

def result_errors?
  result_errors.any?
end

#structure_idObject



54
55
56
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 54

def structure_id
  parent_structure&.id
end

#structure_nameObject



58
59
60
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 58

def structure_name
  parent_structure&.name
end

#success?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 50

def success?
  !error?
end