lib/zendesk_api/actions.rb
# If this resource hasn't been deleted, then create or save it.
# Executes a POST if it is a {#new_record?}, otherwise a PUT.
# Merges returned attributes on success.
# @return [Boolean] Success?
If this resource hasn't been deleted, then create or save it.
Executes a POST if it is a {#new_record?}, otherwise a PUT.
Merges returned attributes on success.
If this resource hasn ' t been deleted then create or save it . Executes a POST if it is a { #new_record? } otherwise a PUT . Merges returned attributes on success .
def save(options={})
      return false if respond_to?(:destroyed?) && destroyed?
      if new_record?
        method = :post
        req_path = path
      else
        method = :put
        req_path = url || path
      end
      req_path = options[:path] if options[:path]
      save_associations
      response = @client.connection.send(method, req_path) do |req|
        req.body = if self.class.unnested_params
          attributes.changes
        else
          {self.class.singular_resource_name.to_sym => attributes.changes}
        end
      end
      @attributes.replace @attributes.deep_merge(response.body[self.class.singular_resource_name] || {})
      @attributes.clear_changes
      true
    end
def save ( options = { } ) return false if respond_to? ( :destroyed? ) && destroyed? if new_record? method = :post req_path = path else method = :put req_path = url || path end req_path = options [ :path ] if options [ :path ] save_associations response = @client . connection . send ( method , req_path ) do | req | req . body = if self . class . unnested_params attributes . changes else { self . class . singular_resource_name . to_sym => attributes . changes } end end @attributes . replace @attributes . deep_merge ( response . body [ self . class . singular_resource_name ] || { } ) @attributes . clear_changes true end
If this resource hasn't been deleted, then create or save it.
If this resource hasn ' t been deleted then create or save it .
None
Boolean
options
<not_specific>