Sha256: b9fcb699e4c0ef8af1be00d39d1fa5c890707d2720fafc8c6293fab2acb4e1e7

Contents?: true

Size: 513 Bytes

Versions: 4

Compression:

Stored size: 513 Bytes

Contents

module Librato
  class Chart < Struct.new(:client, :space, :data)
    def id
      data['id'] ||= find_id
    end

    def name
      data['name']
    end

    def push
      client.post(space.path, data)
    end

    def delete
      client.delete(path)
    end

    private

      def path
        "/v1/spaces/#{space.id}/charts/#{id}"
      end

      def find_id
        chart = space.charts.detect { |chart| chart.name == name }
        chart || fail("Can't find chart")
        chart.id
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
librato-0.0.7 lib/librato/chart.rb
librato-0.0.6 lib/librato/chart.rb
librato-0.0.5 lib/librato/chart.rb
librato-0.0.4 lib/librato/chart.rb