./lib/animoto/response_parsers/base.rb in animoto-0.1.1.beta1 vs ./lib/animoto/response_parsers/base.rb in animoto-1.0.0
- old
+ new
@@ -1,10 +1,15 @@
module Animoto
module ResponseParsers
- extend Support::DynamicClassLoader(File.expand_path(File.dirname(__FILE__)))
+ extend Support::DynamicClassLoader
- # @abstract Override {#parse} and {#unparse} to subclass.
+ dynamic_class_path File.expand_path(File.dirname(__FILE__))
+
+ adapter 'JSON'
+ adapter 'Yajl'
+
+ # @abstract Override {#parse}, {#unparse}, and {#format} (or set @format on the class) to subclass.
class Base
# Returns the format of this parser class.
#
# @return [String] the format
@@ -21,23 +26,23 @@
# Parses a response body into a usable Hash.
#
# @abstract
# @param [String] body the HTTP response body
- # @return [Hash<String,Object>] the parsed response
- # @raise [NotImplementedError] if called on the abstract class
+ # @return [Hash{String=>Object}] the parsed response
+ # @raise [AbstractMethodError] if called on the abstract class
def parse body
- raise NotImplementedError
+ raise AbstractMethodError
end
# Serializes a Hash into the format for this parser.
#
# @abstract
- # @param [Hash<Object,Object>] hash the hash to serialize
+ # @param [Hash{Object=>Object}] hash the hash to serialize
# @return [String] the serialized data
- # @raise [NotImplementedError] if called on the abstract class
+ # @raise [AbstractMethodError] if called on the abstract class
def unparse hash
- raise NotImplementedError
+ raise AbstractMethodError
end
end
end
end
\ No newline at end of file