Class: Brujula::Mergers::Merger

Inherits:
Object
  • Object
show all
Defined in:
lib/brujula/mergers/merger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance:, superinstance:) ⇒ Merger

Returns a new instance of Merger.



6
7
8
9
# File 'lib/brujula/mergers/merger.rb', line 6

def initialize(instance:, superinstance:)
  @superinstance = superinstance
  @instance      = instance
end

Instance Attribute Details

#instanceObject (readonly)

Returns the value of attribute instance.



4
5
6
# File 'lib/brujula/mergers/merger.rb', line 4

def instance
  @instance
end

#superinstanceObject (readonly)

Returns the value of attribute superinstance.



4
5
6
# File 'lib/brujula/mergers/merger.rb', line 4

def superinstance
  @superinstance
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/brujula/mergers/merger.rb', line 11

def call
  case
  when superinstance.is_a?(Brujula::MapObject)
    MapObjectMerger.new(merger_options).call
  when superinstance.is_a?(Brujula::Object)
    ObjectMerger.new(merger_options).call
  else
    superinstance.dup
  end
end

#merger_optionsObject



22
23
24
25
26
27
# File 'lib/brujula/mergers/merger.rb', line 22

def merger_options
  {
    instance:      instance,
    superinstance: superinstance
  }
end