lib/infoblox/resource.rb in infoblox-0.2.4 vs lib/infoblox/resource.rb in infoblox-0.2.5
- old
+ new
@@ -1,11 +1,16 @@
module Infoblox
class Resource
attr_accessor :_ref, :connection
def self.wapi_object(obj=nil)
- obj.nil? ? @wapi_object : @wapi_object = obj
+ if obj.nil?
+ @wapi_object
+ else
+ self.resource_map[obj] = self
+ @wapi_object = obj
+ end
end
##
# Define a writeable remote attribute, i.e. one that
# should show up in post / put operations.
@@ -83,9 +88,17 @@
end
end
def self.resource_uri
BASE_PATH + self.wapi_object
+ end
+
+ ##
+ # A hash that maps Infoblox WAPI object identifiers to subclasses of Resource.
+ # Used by the Search resource for mapping response objects.
+ #
+ def self.resource_map
+ @@resource_map ||= {}
end
def initialize(attrs={})
attrs.each do |k,v|
self.send("#{k}=", v)
\ No newline at end of file