Skip to content

Commit 1378a83

Browse files
committed
Use .merge! instead of .merge when merging defaults with provided options.
1 parent 7a744aa commit 1378a83

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lib/json/ld/api.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class API
8787
# @yieldparam [API]
8888
# @raise [JsonLdError]
8989
def initialize(input, context, options = {}, &block)
90-
@options = {compactArrays: true, rename_bnodes: true}.merge(options)
90+
@options = {compactArrays: true, rename_bnodes: true}.merge!(options)
9191
@options[:validate] = true if @options[:processingMode] == "json-ld-1.0"
9292
@options[:documentLoader] ||= self.class.method(:documentLoader)
9393
@namer = options[:unique_bnodes] ? BlankNodeUniqer.new : (@options[:rename_bnodes] ? BlankNodeNamer.new("b") : BlankNodeMapper.new)
@@ -98,7 +98,7 @@ def initialize(input, context, options = {}, &block)
9898
@value = case input
9999
when Array, Hash then input.dup
100100
when IO, StringIO
101-
@options = {base: input.base_uri}.merge(@options) if input.respond_to?(:base_uri)
101+
@options = {base: input.base_uri}.merge!(@options) if input.respond_to?(:base_uri)
102102

103103
# if input impelements #links, attempt to get a contextUrl from that link
104104
content_type = input.respond_to?(:content_type) ? input.content_type : "application/json"
@@ -113,7 +113,7 @@ def initialize(input, context, options = {}, &block)
113113
when String
114114
remote_doc = @options[:documentLoader].call(input, @options)
115115

116-
@options = {base: remote_doc.documentUrl}.merge(@options)
116+
@options = {base: remote_doc.documentUrl}.merge!(@options)
117117
context_ref = remote_doc.contextUrl
118118

119119
case remote_doc.document
@@ -322,7 +322,7 @@ def self.frame(input, frame, options = {})
322322
requireAll: true,
323323
omitDefault: false,
324324
documentLoader: method(:documentLoader)
325-
}.merge(options)
325+
}.merge!(options)
326326

327327
framing_state = {
328328
graphs: {'@default' => {}, '@merged' => {}},
@@ -471,7 +471,7 @@ def self.toRdf(input, options = {}, &block)
471471
# @return [Object, Hash]
472472
# If a block is given, the result of evaluating the block is returned, otherwise, the expanded JSON-LD document
473473
def self.fromRdf(input, options = {}, &block)
474-
options = {useNativeTypes: false}.merge(options)
474+
options = {useNativeTypes: false}.merge!(options)
475475
result = nil
476476

477477
API.new(nil, nil, options) do |api|

lib/json/ld/context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ def compact_iri(iri, options = {})
990990
# @raise [RDF::ReaderError] if the iri cannot be expanded
991991
# @see http://json-ld.org/spec/latest/json-ld-api/#value-expansion
992992
def expand_value(property, value, options = {})
993-
options = {useNativeTypes: false}.merge(options)
993+
options = {useNativeTypes: false}.merge!(options)
994994
depth(options) do
995995
debug("expand_value") {"property: #{property.inspect}, value: #{value.inspect}"}
996996

lib/json/ld/expand.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Expand
1515
# Ensure output objects have keys ordered properly
1616
# @return [Array, Hash]
1717
def expand(input, active_property, context, options = {})
18-
options = {ordered: true}.merge(options)
18+
options = {ordered: true}.merge!(options)
1919
debug("expand") {"input: #{input.inspect}, active_property: #{active_property.inspect}, context: #{context.inspect}"}
2020
result = case input
2121
when Array

lib/json/ld/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def compare_values(v1, v2)
118118
# true to allow duplicates, false not to (uses
119119
# a simple shallow comparison of subject ID or value).
120120
def add_value(subject, property, value, options = {})
121-
options = {property_is_array: false, allow_duplicate: true}.merge(options)
121+
options = {property_is_array: false, allow_duplicate: true}.merge!(options)
122122

123123
if value.is_a?(Array)
124124
subject[property] = [] if value.empty? && options[:property_is_array]

0 commit comments

Comments
 (0)