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.4.24 lib/spark_api/models/note.rb
spark_api-1.4.23 lib/spark_api/models/note.rb
spark_api-1.4.22 lib/spark_api/models/note.rb
spark_api-1.4.21 lib/spark_api/models/note.rb
spark_api-1.4.20 lib/spark_api/models/note.rb
spark_api-1.4.19 lib/spark_api/models/note.rb
spark_api-1.4.18 lib/spark_api/models/note.rb
spark_api-1.4.17 lib/spark_api/models/note.rb
spark_api-1.4.16 lib/spark_api/models/note.rb
spark_api-1.4.15 lib/spark_api/models/note.rb
spark_api-1.4.14 lib/spark_api/models/note.rb
spark_api-1.4.13 lib/spark_api/models/note.rb
spark_api-1.4.12 lib/spark_api/models/note.rb
spark_api-1.4.11 lib/spark_api/models/note.rb
spark_api-1.4.10 lib/spark_api/models/note.rb
spark_api-1.4.9 lib/spark_api/models/note.rb
spark_api-1.4.8 lib/spark_api/models/note.rb
spark_api-1.4.6 lib/spark_api/models/note.rb
spark_api-1.4.5 lib/spark_api/models/note.rb
spark_api-1.4.4 lib/spark_api/models/note.rb