From 48b56ee6da3f8df57e5799d4cd81fc7f412b1148 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 30 Nov 2015 01:34:33 +0100 Subject: [PATCH] Array#to_h is new in Ruby 2.1, we still support 2.0 --- lib/diaspora_federation/salmon/xml_payload.rb | 4 ++-- lib/diaspora_federation/test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/diaspora_federation/salmon/xml_payload.rb b/lib/diaspora_federation/salmon/xml_payload.rb index d5a8d1c..40d527e 100644 --- a/lib/diaspora_federation/salmon/xml_payload.rb +++ b/lib/diaspora_federation/salmon/xml_payload.rb @@ -89,7 +89,7 @@ module DiasporaFederation # and attached to resulted hash as string. It is intended to build a hash # invariable of an Entity definition, in order to support receiving objects # from the future versions of Diaspora, where new elements may have been added. - data = root_node.element_children.map { |child| + data = Hash[root_node.element_children.map { |child| xml_name = child.name property = klass.class_props.find {|prop| prop[:xml_name].to_s == xml_name } if property @@ -97,7 +97,7 @@ module DiasporaFederation else [xml_name, child.text] end - }.to_h + }] Entities::Relayable.verify_signatures(data) if klass.included_modules.include?(Entities::Relayable) diff --git a/lib/diaspora_federation/test.rb b/lib/diaspora_federation/test.rb index 789f53a..cac96f1 100644 --- a/lib/diaspora_federation/test.rb +++ b/lib/diaspora_federation/test.rb @@ -11,9 +11,9 @@ module DiasporaFederation # @param [Entity.Class] klass entity type to sort according to # @return [Hash] sorted hash def self.sort_hash(data, klass) - klass.class_props.map { |prop| + Hash[klass.class_props.map { |prop| [prop[:name], data[prop[:name]]] unless data[prop[:name]].nil? - }.compact.to_h + }.compact] end # Generates attributes for entity constructor with correct signatures in it