Sha256: d544984021f8991ddcb8c1e93ff5be3f96f230f71e2e3ffe6100b93958027ac0

Contents?: true

Size: 1020 Bytes

Versions: 73

Compression:

Stored size: 1020 Bytes

Contents

module SparkApi
  module Models
    class Note < Base
      extend Subresource 
      self.element_name = "notes" # not sure this is really of any use...
      
      def self.get(options={})
        ret = super(options)
        if ret.empty?
          return nil
        else
          return ret.first
        end
      end

      def save(arguments={})
        begin
          return save!(arguments)
        rescue BadResourceRequest => e
        rescue NotFound => e
          # log and leave
          SparkApi.logger.error("Failed to save note #{self} (path: #{self.class.path}): #{e.message}")
        end 
        false
      end 

      def save!(args={})
        args.merge(:Notes => attributes['Note'])
        results = connection.put(self.class.path, {:Note => attributes['Note']}, args)
        result = results.first
        attributes['ResourceUri'] = result['ResourceUri']
        true
      end 

      def delete(args={})
        connection.delete(self.class.path, args)
      end

    end
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
spark_api-1.6.3 lib/spark_api/models/note.rb
spark_api-1.6.2 lib/spark_api/models/note.rb
spark_api-1.6.1 lib/spark_api/models/note.rb
spark_api-1.5.7 lib/spark_api/models/note.rb
spark_api-1.6.0 lib/spark_api/models/note.rb
spark_api-1.5.6 lib/spark_api/models/note.rb
spark_api-1.5.5 lib/spark_api/models/note.rb
spark_api-1.5.4 lib/spark_api/models/note.rb
spark_api-1.5.3 lib/spark_api/models/note.rb
spark_api-1.5.2 lib/spark_api/models/note.rb
spark_api-1.5.1 lib/spark_api/models/note.rb
spark_api-1.5.0 lib/spark_api/models/note.rb
spark_api-1.4.34 lib/spark_api/models/note.rb
spark_api-1.4.32 lib/spark_api/models/note.rb
spark_api-1.4.31 lib/spark_api/models/note.rb
spark_api-1.4.29 lib/spark_api/models/note.rb
spark_api-1.4.28 lib/spark_api/models/note.rb
spark_api-1.4.27 lib/spark_api/models/note.rb
spark_api-1.4.26 lib/spark_api/models/note.rb
spark_api-1.4.25 lib/spark_api/models/note.rb