Sha256: 45784d9bd53b7cbe046e058d257eac45ac16ef2dc54977fab2842250de426e21
Contents?: true
Size: 1.03 KB
Versions: 10
Compression:
Stored size: 1.03 KB
Contents
module Workarea decorate HashUpdate, with: :product_additional_details do decorated do # Place code to decorate here that would normally go on the class # level, e.g.: # # field :name, type: String end class_methods do # Place methods to define on the class level here. These methods # will be available by calling HashUpdate.your_method. Do # not prefix these methods with `self.` end def result_grouped apply_to_grouped(@original.deep_dup) end private def apply_to_grouped(hash) @adds.each do |tuple| key, value = *tuple hash[key] = value end @updates.each do |tuple| key, value = *tuple hash[key] = value end @removes.each do |key| hash.delete(key) end hash.delete_if { |k, v| k.blank? || v.blank? } end # Instance methods can go right in the main definition of the # decorator, as it is a module that gets prepended into the class of # your choice. end end
Version data entries
10 entries across 10 versions & 1 rubygems