Sha256: 8d4c7504c2b899648827c63caf1abe863e6e476a4a82bfc85286d9f0d67a4e4c
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# A lightweight resource class that will do much of the work of ActiveResource # without the big dependencies. module ZerigoDNS::Resource module ClassMethods # Removes the root from the response and hands it off to the class to process it # Processes an array response by delegating to the includer's self.from_response # @param [Faraday::Response] response The response # @return [Object] The result of the parsed response. def process_response response without_root = response.body.values.first case when without_root.is_a?(Array) then process_array(response, without_root) when without_root.is_a?(Hash) then from_response(response, without_root) else without_root end end # Processes an array response by delegating to the includer's self.from_response # @param [Faraday::Response] response The response # @param [Array] body The response body, with root removed # @return [Array] The resultant array. def process_array response, body body.map do |element| from_response response, element end end end def self.included includer includer.send :include, Attributes includer.send :include, Rest includer.send :include, Naming includer.send :extend, ClassMethods end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zerigodns-1.1.0 | lib/zerigodns/resource.rb |