Class: Abiquo::ResourceCollection
Instance Method Summary
collapse
#xml
Constructor Details
#initialize(url, auth, xml = nil, options = {}) ⇒ ResourceCollection
133
134
135
136
137
138
|
# File 'lib/abiquo.rb', line 133
def initialize(url, auth, xml = nil, options = {})
@url = url
@auth = auth
@xml = xml if options.empty?
@options = options
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
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 rest_options.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
|