Sha256: f9528cc6ed8ab1792ee4cc2e7019ee750f6a1cd5d9d25e4497b0e5d745ee7c86
Contents?: true
Size: 1001 Bytes
Versions: 1
Compression:
Stored size: 1001 Bytes
Contents
module FullCircle class ResponseParser attr_reader :api_method_name, :object_name def initialize(api_method_name, object_name) @api_method_name= api_method_name @object_name = object_name end def parse(response) if response attrs = response.parsed_response parse_response(attrs, response_name, object_name) end end private # example # parseResponse(attrs, "city_getEventAreasResponse", "eventArea") def parse_response(attrs, response_name, object_name) if attrs[response_name][object_name.pluralize].nil? [] else response_attrs = Array.wrap(attrs[response_name][object_name.pluralize][object_name]) builder = ObjectBuilder.new response_attrs.collect do |response_attr_set| builder.from_api_hash(response_attr_set) end end end def response_name @response_name ||= "#{api_method_name.gsub(/\./,'_')}Response" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
full_circle-0.1.0 | lib/full_circle/response_parser.rb |