Skip to content

Commit 644659a

Browse files
committed
model: Avoid frozen literal warning
Clone the type and mutate it instead of the frozen literal.
1 parent d5a0948 commit 644659a

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

lib/fhir_models/bootstrap/model.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ def ==(other)
3939
def method_missing(method_name, *_args, &_block)
4040
if defined?(self.class::MULTIPLE_TYPES) && self.class::MULTIPLE_TYPES[method_name.to_s]
4141
self.class::MULTIPLE_TYPES[method_name.to_s].each do |type|
42-
type[0] = type[0].upcase
43-
value = send("#{method_name}#{type}".to_sym)
42+
dup_type = type.dup
43+
dup_type[0] = dup_type[0].upcase
44+
value = send("#{method_name}#{dup_type}".to_sym)
4445
return value unless value.nil?
4546
end
4647
return nil
@@ -284,8 +285,9 @@ def primitive?(datatype, value)
284285
end
285286
deprecate :is_primitive?, :primitive?
286287

287-
def check_binding_uri(uri, value)
288+
def check_binding_uri(orig_uri, value)
288289
valid = false
290+
uri = orig_uri.dup
289291
# Strip off the |4.0.0 or |4.0.1 or |2014-03-26 or similar from the ends of URLs
290292
uri&.gsub!(/\|[A-Za-z0-9.\-]*/, '')
291293
valueset = versioned_fhir_module::Definitions.get_codes(uri)

lib/fhir_models/fhirpath/evaluate.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ def self.evaluate(expression, hash, parent = nil)
1313

1414
# Get a value from a hash, with some special handling of
1515
# self references
16-
def self.get(key, hash)
17-
return @@context if ['$context', '$resource'].include?(key)
18-
return @@parent if key == '$parent'
19-
return 'http://unitsofmeasure.org' if key == '%ucum'
20-
return 'http://snomed.info/sct' if key == '%sct'
21-
return 'http://loinc.org' if key == '%loinc'
22-
return key.gsub!(/\A\'|\'\Z/, '') if key.start_with?("'") && key.end_with?("'")
16+
def self.get(orig_key, hash)
17+
return @@context if ['$context', '$resource'].include?(orig_key)
18+
return @@parent if orig_key == '$parent'
19+
return 'http://unitsofmeasure.org' if orig_key == '%ucum'
20+
return 'http://snomed.info/sct' if orig_key == '%sct'
21+
return 'http://loinc.org' if orig_key == '%loinc'
22+
key = orig_key.dup
23+
return key.gsub!(/\A\'|\'\Z/, '') if orig_key.start_with?("'") && orig_key.end_with?("'")
2324
key.gsub!(/\A"|"\Z/, '') # remove quotes around path if they exist
2425
if hash.is_a?(Array)
2526
response = []

0 commit comments

Comments
 (0)