Class: Catalogcat::ApiArray

Inherits:
Bearcat::ApiArray show all
Defined in:
lib/catalogcat/api_array.rb

Instance Attribute Summary

Attributes inherited from Bearcat::ApiArray

#members, #raw_response

Class Method Summary collapse

Methods inherited from Bearcat::ApiArray

#[], #all_pages!, #all_pages_each, #each, #each_page, #initialize, #last, make_indifferent, #method, #page_count, #pages?, process_response

Constructor Details

This class inherits a constructor from Bearcat::ApiArray

Class Method Details

.array_key(response) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/catalogcat/api_array.rb', line 5

def self.array_key(response)
  key = nil
  if response.env[:method] == :get
    path = response.env[:url].path
    key = 'courses' if path =~ %r{.*/courses}
    key = 'course' if path =~ %r{.*/courses/[0-9]*}
    key = 'catalogs' if path =~ %r{.*/catalogs}
    key = 'enrollments' if path =~ %r{.*/enrollments}
    key = 'order' if path =~ %r{.*/order/[0-9]*}
    key = 'orders' if path =~ %r{.*/orders}
    key = 'completed_certificates' if path =~ %r{.*/completed_certificates}
    key = 'user_registrations' if path =~ %r{.*/user_registrations}
    key = 'email_domain_sets' if path =~ %r{.*/email_domain_sets}
  end
  key.present? ? key : super(response)
end