Class: ElasticGraph::Indexer::Operation::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/elastic_graph/indexer/operation/result.rb

Overview

Describes the result of an operation. :category value will be one of: [:success, :noop, :failure]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



16
17
18
# File 'lib/elastic_graph/indexer/operation/result.rb', line 16

def category
  @category
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



16
17
18
# File 'lib/elastic_graph/indexer/operation/result.rb', line 16

def description
  @description
end

#operationObject (readonly)

Returns the value of attribute operation

Returns:

  • (Object)

    the current value of operation



16
17
18
# File 'lib/elastic_graph/indexer/operation/result.rb', line 16

def operation
  @operation
end

Class Method Details

.failure_of(operation, description) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/elastic_graph/indexer/operation/result.rb', line 34

def self.failure_of(operation, description)
  Result.new(
    category: :failure,
    operation: operation,
    description: description
  )
end

.noop_of(operation, description) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/elastic_graph/indexer/operation/result.rb', line 26

def self.noop_of(operation, description)
  Result.new(
    category: :noop,
    operation: operation,
    description: description
  )
end

.success_of(operation) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/elastic_graph/indexer/operation/result.rb', line 18

def self.success_of(operation)
  Result.new(
    category: :success,
    operation: operation,
    description: nil
  )
end

Instance Method Details

#eventObject



46
47
48
# File 'lib/elastic_graph/indexer/operation/result.rb', line 46

def event
  operation.event
end

#event_idObject



50
51
52
# File 'lib/elastic_graph/indexer/operation/result.rb', line 50

def event_id
  EventID.from_event(event)
end

#inspectObject Also known as: to_s



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/elastic_graph/indexer/operation/result.rb', line 61

def inspect
  parts = [
    self.class.name,
    operation_type.inspect,
    category.inspect,
    event_id,
    description
  ].compact

  "#<#{parts.join(" ")}>"
end

#operation_typeObject



42
43
44
# File 'lib/elastic_graph/indexer/operation/result.rb', line 42

def operation_type
  operation.type
end

#summaryObject



54
55
56
57
58
59
# File 'lib/elastic_graph/indexer/operation/result.rb', line 54

def summary
  # :nocov: -- `description == nil` case is not covered; not simple to test.
  suffix = description ? "--#{description}" : nil
  # :nocov:
  "<#{operation.description} #{event_id} #{category}#{suffix}>"
end