lib/siren_client/entity.rb in siren_client-1.0.0 vs lib/siren_client/entity.rb in siren_client-1.0.1
- old
+ new
@@ -123,18 +123,18 @@
str.underscore.gsub(' ', '_')
end
def parse_data
return if @payload.nil?
- @classes = @payload['class'] || []
- @properties = @payload['properties'] || { }
- @entities = @payload['entities'] || []
+ @classes = (@payload['class'] || []).clone
+ @properties = (@payload['properties'] || { }).clone
+ @entities = (@payload['entities'] || []).clone
@entities.map! do |data|
self.class.new(data, @config)
end
- @rels = @payload['rel'] || []
- @links = @payload['links'] || []
+ @rels = (@payload['rel'] || []).clone
+ @links = (@payload['links'] || []).clone
@links.map! do |data|
Link.new(data, @config)
end
# Convert links into a hash
@links = @links.inject({}) do |hash, link|
@@ -148,10 +148,10 @@
end
# Ensure the rel name is a valid hash key
hash[hash_rel] = link
hash
end
- @actions = @payload['actions'] || []
+ @actions = (@payload['actions'] || []).clone
@actions.map! do |data|
Action.new(data, @config)
end
# Convert actions into a hash
@actions = @actions.inject({}) do |hash, action|