Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/application_config/deep_merge.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module ApplicationConfig
module DeepMerge

class InvalidParameter < StandardError; end

DEFAULT_FIELD_KNOCKOUT_PREFIX = '--'

# Deep Merge core documentation.
Expand All @@ -18,7 +19,7 @@ class InvalidParameter < StandardError; end
# Results: {:x => [1,2,3,4,5,'6'], :y => 2}
# By default, "deep_merge!" will overwrite any unmergeables and merge everything else.
# To avoid this, use "deep_merge" (no bang/exclamation mark)
#
#
# Options:
# Options are specified in the last parameter passed, which should be in hash format:
# hash.deep_merge!({:x => [1,2]}, {:knockout_prefix => '--'})
Expand All @@ -34,7 +35,7 @@ class InvalidParameter < StandardError; end
# Set to true to get console output of merge process for debugging
#
# Selected Options Details:
# :knockout_prefix => The purpose of this is to provide a way to remove elements
# :knockout_prefix => The purpose of this is to provide a way to remove elements
# from existing Hash by specifying them in a special way in incoming hash
# source = {:x => ['--1', '2']}
# dest = {:x => ['1', '3']}
Expand All @@ -52,9 +53,9 @@ class InvalidParameter < StandardError; end
# dest = {:x => ['5','6','7,8']}
# dest.deep_merge!(source, {:unpack_arrays => ','})
# Results: {:x => ['1','2','3','4','5','6','7','8'}
# Why: If receiving data from an HTML form, this makes it easy for a checkbox
# Why: If receiving data from an HTML form, this makes it easy for a checkbox
# to pass multiple values from within a single HTML element
#
#
# There are many tests for this library - and you can learn more about the features
# and usages of deep_merge! by just browsing the test examples
def DeepMerge.deep_merge!(source, dest, options = {})
Expand Down Expand Up @@ -178,4 +179,5 @@ def DeepMerge::clear_or_nil(obj)
obj
end

end # module DeepMerge
end # module DeepMerge
end