Skip to content

Commit

Permalink
remove SchemaObjectBase#merge, it is now done by SAFE_MODIFIED_COPY_M…
Browse files Browse the repository at this point in the history
…ETHODS. I don't think stripping the argument is needed now.
  • Loading branch information
notEthan committed Apr 24, 2018
1 parent e0515d2 commit 1866e18
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions lib/scorpio/schema_object_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,30 +155,6 @@ def []=(property_name, value)
hash.merge(property_name => value)
end
end

def merge(other)
# we want to strip the containers from this before we merge
# this is kind of annoying. wish I had a better way.
other_stripped = ycomb do |striprec|
proc do |stripobject|
stripobject = stripobject.object if stripobject.is_a?(Scorpio::SchemaObjectBase)
stripobject = stripobject.content if stripobject.is_a?(Scorpio::JSON::Node)
if stripobject.is_a?(Hash)
stripobject.map { |k, v| {striprec.call(k) => striprec.call(v)} }.inject({}, &:update)
elsif stripobject.is_a?(Array)
stripobject.map(&striprec)
elsif stripobject.is_a?(Symbol)
stripobject.to_s
elsif [String, TrueClass, FalseClass, NilClass, Numeric].any? { |c| stripobject.is_a?(c) }
stripobject
else
raise(TypeError, "bad (not jsonifiable) object: #{stripobject.pretty_inspect}")
end
end
end.call(other)

self.class.new(object.merge(other_stripped))
end
end

module SchemaObjectBaseArray
Expand Down

0 comments on commit 1866e18

Please sign in to comment.