Class: Abiquo::ResourceCollection
- Includes:
- HttpAccessor
- Defined in:
- lib/abiquo.rb
Instance Method Summary collapse
- #create(attrs = {}) ⇒ Object
-
#initialize(url, auth, xml = nil, options = {}) ⇒ ResourceCollection
constructor
A new instance of ResourceCollection.
Methods included from HttpAccessor
Constructor Details
#initialize(url, auth, xml = nil, options = {}) ⇒ ResourceCollection
Returns a new instance of ResourceCollection.
133 134 135 136 137 138 |
# File 'lib/abiquo.rb', line 133 def initialize(url, auth, xml = nil, = {}) @url = url @auth = auth @xml = xml if .empty? @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object (private)
157 158 159 |
# File 'lib/abiquo.rb', line 157 def method_missing(meth, *args, &blk) resources.send(meth, *args, &blk) end |
Instance Method Details
#create(attrs = {}) ⇒ Object
140 141 142 143 144 145 |
# File 'lib/abiquo.rb', line 140 def create(attrs = {}) raise Abiquo::NotAllowed.new(:POST, url) unless .include?(:POST) response = http.resource(url_with_params).post(attrs.to_xml(:root => object_type, :convert_links => true), :content_type => "application/xml") doc = Nokogiri.parse(response.body) Resource.new(nil, @auth, doc.root) end |