lib/uwaterlooapi.rb in uwaterlooapi-0.0.2 vs lib/uwaterlooapi.rb in uwaterlooapi-0.0.3
- old
+ new
@@ -5,13 +5,18 @@
class UWaterlooAPI
VERSION = '0.0.1'
include Routes
def initialize(api_key)
- @@routes.map { |r| r.split('/')[1] }.uniq.map(&:to_sym).each do |route|
+ get_base_routes.each do |route|
self.class.send :define_method, route do
UWaterlooAPIQuery.new "/#{route}", "/#{route}", api_key
end
end
end
+private
+
+ def get_base_routes
+ @base_routes ||= @@routes.map { |r| r.split('/')[1] }.uniq.map(&:to_sym)
+ end
end