Class: Workarea::HashUpdate

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/hash_update.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original: {}, adds: [], updates: [], removes: []) ⇒ HashUpdate

Returns a new instance of HashUpdate.



8
9
10
11
12
13
# File 'app/services/workarea/hash_update.rb', line 8

def initialize(original: {}, adds: [], updates: [], removes: [])
  @original = original
  @adds = Array(adds).flatten.each_slice(2).to_a
  @updates = Array(updates).flatten.each_slice(2).to_a
  @removes = Array(removes).flatten
end

Class Method Details

.parse_values(value) ⇒ Object



3
4
5
6
# File 'app/services/workarea/hash_update.rb', line 3

def self.parse_values(value)
  parsed = CSV.parse(value).first
  parsed.map(&:to_s).map(&:strip).reject(&:blank?) if parsed.present?
end

Instance Method Details

#apply(hash) ⇒ Object

Deprecated.

TODO v3.6 remove this method, doesn’t work when the field is localized



21
22
23
24
# File 'app/services/workarea/hash_update.rb', line 21

def apply(hash)
  Workarea.deprecation.deprecate_methods(self.class, apply: :result)
  apply_to(hash)
end

#resultObject



15
16
17
# File 'app/services/workarea/hash_update.rb', line 15

def result
  apply_to(@original.deep_dup)
end