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

Inherits:
Logic::BaseModel show all
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 Common::GraphQL::Model::AsInput

#as_input

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

#as_update, #dirty?

Instance Method Details

#conflictingIds?Boolean

Returns:

  • (Boolean)


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

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

#error?Boolean

Returns:

  • (Boolean)


36
37
38
39
40
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 36

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

#error_docObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 42

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

#ok?Boolean

Returns:

  • (Boolean)


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

def ok?
  ok != false
end

#parent_structureObject

Note:

draft is in a collection of drafts



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

def parent_structure
  return unless _parent != self
  return unless _parent._parent != _parent
  return unless _parent.is_a?(Base::LocationStructure)

  _parent._parent
end

#result_errorsObject



83
84
85
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 83

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

#result_errors?Boolean

Returns:

  • (Boolean)


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

def result_errors?
  result_errors.any?
end

#structure_idObject



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

def structure_id
  parent_structure&.id
end

#structure_nameObject



62
63
64
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 62

def structure_name
  parent_structure&.name
end

#success?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/ecoportal/api/graphql/base/location_structure/draft.rb', line 32

def success?
  !error?
end