class CPEE::Properties::PostItem

Public Instance Methods

response() click to toggle source
# File lib/cpee/implementation_properties.rb, line 416
def response
  item = @a[0]
  id = @a[1]
  opts = @a[2]
  if opts[:statemachine].readonly? id
    @status = 423
  else
    begin
      doc = XML::Smart::string(@p[0].value.read)
      val = doc.find("/*").map do |ele|
        [ele.qname.name, ele.text]
      end.to_h
      if not CPEE::Persistence::extract_item(id,opts,File.join(@r.first,val.keys.first))
        CPEE::Persistence::set_list(id,opts,item,val)
        Riddl::Parameter::Simple.new('id',val.keys.first)
      else
        @status= 409
      end
    rescue => e
      @status = 400
    end
  end
  nil
end