Class: DeltaCore::DeltaResult

Inherits:
Object
  • Object
show all
Defined in:
lib/delta_core/delta_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(added: [], removed: [], modified: []) ⇒ DeltaResult

Returns a new instance of DeltaResult.



7
8
9
10
11
12
# File 'lib/delta_core/delta_result.rb', line 7

def initialize(added: [], removed: [], modified: [])
  @added    = Array(added).freeze
  @removed  = Array(removed).freeze
  @modified = Array(modified).freeze
  freeze
end

Instance Attribute Details

#added ⇒ Object (readonly)

Returns the value of attribute added.



5
6
7
# File 'lib/delta_core/delta_result.rb', line 5

def added
  @added
end

#modified ⇒ Object (readonly)

Returns the value of attribute modified.



5
6
7
# File 'lib/delta_core/delta_result.rb', line 5

def modified
  @modified
end

#removed ⇒ Object (readonly)

Returns the value of attribute removed.



5
6
7
# File 'lib/delta_core/delta_result.rb', line 5

def removed
  @removed
end

Instance Method Details

#empty? ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/delta_core/delta_result.rb', line 14

def empty?
  added.empty? && removed.empty? && modified.empty?
end

#merge(other) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/delta_core/delta_result.rb', line 18

def merge(other)
  self.class.new(
    added: added + other.added,
    removed: removed + other.removed,
    modified: modified + other.modified
  )
end

#render(renderer) ⇒ Object



26
27
28
# File 'lib/delta_core/delta_result.rb', line 26

def render(renderer)
  renderer.call(self)
end