Class: Fassbinder::Response
- Inherits:
-
Object
- Object
- Fassbinder::Response
- Includes:
- Enumerable
- Defined in:
- lib/fassbinder/response.rb
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Yields each snapshot to given block.
- #errors ⇒ Object
-
#initialize(response, locale) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(response, locale) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fassbinder/response.rb', line 8 def initialize(response, locale) unless response.valid? = if response.has_errors? response.errors.first['Message'] else response.code end raise InvalidResponse, end @response = response @locale = locale.to_sym end |
Instance Method Details
#each(&block) ⇒ Object
Yields each snapshot to given block.
26 27 28 |
# File 'lib/fassbinder/response.rb', line 26 def each(&block) @response.each('Item') { |doc| block.call(build_book(doc)) } end |
#errors ⇒ Object
30 31 32 33 34 |
# File 'lib/fassbinder/response.rb', line 30 def errors @response.errors.map do |error| error['Message'].scan(/[0-9A-Z]{10}/).first rescue nil end.compact end |