lib/rgeoserver/resource.rb in rgeoserver-0.5.4 vs lib/rgeoserver/resource.rb in rgeoserver-0.5.5

- old
+ new

@@ -64,21 +64,31 @@ self.class.update_method end # Modify or save the resource - # @param [Hash] options + # @param [Hash] options / query parameters # @return [RGeoServer::ResourceInfo] def save options = {} @previously_changed = changes @changed_attributes.clear run_callbacks :save do if new? - @catalog.add(@route, message, create_method) - clear + if self.respond_to?(:create_route) + raise "Resource cannot be created directly" if create_route.nil? + route = create_route + else + route = {@route => nil} + end + + options = create_options.merge(options) if self.respond_to?(:create_options) + @catalog.add(route, message, create_method, options) + clear else - @catalog.modify({@route => @name}, message, update_method) #unless changes.empty? + options = update_options.merge(options) if self.respond_to?(:update_options) + route = self.respond_to?(:update_route)? update_route : {@route => @name} + @catalog.modify(route, message, update_method, options) #unless changes.empty? end self end end @@ -129,31 +139,12 @@ end def profile_xml_to_ng profile_xml Nokogiri::XML(profile_xml).xpath(self.class.member_xpath) end - + def profile_xml_to_hash profile_xml - doc = profile_xml_to_ng profile_xml - h = {'name' => doc.at_xpath('//name').text.strip, 'enabled' => @enabled } - doc.xpath('//atom:link/@href', "xmlns:atom"=>"http://www.w3.org/2005/Atom" ).each{ |l| - target = l.text.match(/([a-zA-Z]+)\.xml$/)[1] - if !target.nil? && target != l.parent.parent.name.to_s.downcase - begin - h[l.parent.parent.name.to_s] << target - rescue - h[l.parent.parent.name.to_s] = [] - end - else - h[l.parent.parent.name.to_s] = begin - response = @catalog.fetch_url l.text - Nokogiri::XML(response).xpath('//name/text()').collect{ |a| a.text } - rescue RestClient::ResourceNotFound - [] - end.freeze - end - } - h + raise NotImplementedError end end end