lib/ably/models/paginated_resource.rb in ably-0.6.2 vs lib/ably/models/paginated_resource.rb in ably-0.7.0

- old
+ new

@@ -3,11 +3,11 @@ # the array of resources using {#first_page}, {#next_page}, {#first_page?} and {#last_page?} # # Paging information is provided by Ably in the LINK HTTP headers class PaginatedResource include Enumerable - include Ably::Modules::AsyncWrapper + include Ably::Modules::AsyncWrapper if defined?(EventMachine) # @param [Faraday::Response] http_response Initial HTTP response from an Ably request to a paged resource # @param [String] base_url Base URL for request that generated the http_response so that subsequent paged requests can be made # @param [Client] client {Ably::Client} used to make the request to Ably # @param [Hash] options Options for this paged resource @@ -25,11 +25,13 @@ @each_block = each_block @make_async = options.fetch(:async_blocking_operations, false) @body = if @coerce_into http_response.body.map do |item| - Kernel.const_get(@coerce_into).new(item) + @coerce_into.split('::').inject(Kernel) do |base, klass_name| + base.public_send(:const_get, klass_name) + end.new(item) end else http_response.body end @@ -166,9 +168,10 @@ } end def async_wrap_if(is_realtime, success_callback, &operation) if is_realtime + raise 'EventMachine is required for asynchronous operations' unless defined?(EventMachine) async_wrap success_callback, &operation else yield end end