Sha256: 2462a40ff9e53684505fdbacea9ede37c78e12180867666ed214ecd0326d95f8

Contents?: true

Size: 918 Bytes

Versions: 24

Compression:

Stored size: 918 Bytes

Contents

class Mite::Tracker < Mite::Base
  
  self.collection_name = "tracker"
  
  def self.current
    tracking_time_entry = connection.get(collection_path, headers)["tracking_time_entry"]
    tracking_time_entry ? instantiate_record(tracking_time_entry) : nil
  end
  
  def self.start(time_entry_or_id)
    id = time_entry_or_id.is_a?(Mite::TimeEntry) ? time_entry_or_id.id : time_entry_or_id
    self.new(:id => id).start
  end
  
  def self.stop
    tracker = current 
    tracker ? tracker.stop : false
  end
  
  def start
    response = connection.put(element_path(prefix_options), encode, self.class.headers)
    load(self.class.format.decode(response.body)["tracking_time_entry"])
    response.is_a?(Net::HTTPSuccess) ? self : false
  end
  
  def stop
    connection.delete(element_path, self.class.headers).is_a?(Net::HTTPSuccess) ? self : false
  end
  
  def time_entry
    Mite::TimeEntry.find(id)
  end
  
end

Version data entries

24 entries across 24 versions & 5 rubygems

Version Path
Overbryd-mighty-mite-0.1.0 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
Overbryd-mighty-mite-0.1.1 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
Overbryd-mighty-mite-0.1.2 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
Overbryd-mighty-mite-0.1.3 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
Overbryd-mite.cmd-0.1.3 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
Overbryd-mite.cmd-0.1.4 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
Overbryd-mite.cmd-0.1.5 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
Overbryd-mite.cmd-0.1.7 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
Overbryd-mite.cmd-0.1.9 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
yolk-mite-rb-0.0.2 lib/mite/tracker.rb
yolk-mite-rb-0.0.3 lib/mite/tracker.rb
mite-rb-0.4.4 lib/mite/tracker.rb
mite-rb-0.4.3 lib/mite/tracker.rb
mite-rb-0.4.2 lib/mite/tracker.rb
mite-rb-0.4.1 lib/mite/tracker.rb
mite-rb-0.4.0 lib/mite/tracker.rb
mite-rb-0.3.0 lib/mite/tracker.rb
mite.cmd-0.1.10 vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
mite-rb-0.2.4 lib/mite/tracker.rb
mite-rb-0.2.3 lib/mite/tracker.rb