lib/infoblox/resource.rb in infoblox-0.0.4 vs lib/infoblox/resource.rb in infoblox-0.0.5

- old
+ new

@@ -19,15 +19,23 @@ def self.remote_attrs @remote_attrs ||= [] end + def self._return_fields + self.remote_attrs.join(",") + end + + def self.default_params + {:_return_fields => self._return_fields} + end + ## # Return an array of all records for this resource. # def self.all - JSON.parse(connection.get(resource_uri).body).map do |item| + JSON.parse(connection.get(resource_uri, default_params).body).map do |item| new(item) end end ## @@ -38,10 +46,11 @@ # # Example: filter resources by name. # {"name~" => "foo.*bar"} # def self.find(params) + params = default_params.merge(params) JSON.parse(connection.get(resource_uri, params).body).map do |item| new(item) end end @@ -72,9 +81,13 @@ connection.delete(resource_uri).status == 200 end def get(params={}) connection.get(resource_uri, params) + end + + def put + connection.put(resource_uri, remote_attribute_hash) end def resource_uri self._ref.nil? ? self.class.resource_uri : (BASE_PATH + self._ref) end \ No newline at end of file