Sha256: 15037c4374b39eaefc63502ea0951ac4692f2c2d6787d1fb969449bd629d034c

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

class Mite::TimeEntry < Mite::Base

  def service
    @service ||= Mite::Service.find(service_id) unless service_id.blank?
  end

  def service=(service)
    self.service_id = service ? service.id : nil
    @service = service
  end

  def project
    @project ||= Mite::Project.find(project_id) unless project_id.blank?
  end

  def project=(project)
    self.project_id = project ? project.id : nil
    @project = project
  end

  def customer
    @customer ||= begin
      p = project
      p.customer unless p.blank?
    end
  end

  def tracking?
    !!attributes["tracker"]
  end

  def start_tracker
    attributes["tracker"] = Mite::Tracker.start(id) || nil
  end

  def stop_tracker
    Mite::Tracker.stop if tracking?
  end

  def load(*attrs)
    super
    if attributes["tracking"]
      attributes["tracker"] = Mite::Tracker.new.load(attributes.delete("tracking").attributes)
    end
    self
  end

  class << self
    def find_every(options={})
      return super(options) if !options[:params] || !options[:params][:group_by]
      Mite::TimeEntryGroup.all(options)
    end
  end
end

require 'mite/time_entry/bookmark'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mite-rb-0.5.4 lib/mite/time_entry.rb
mite-rb-0.5.3 lib/mite/time_entry.rb
mite-rb-0.5.2 lib/mite/time_entry.rb
mite-rb-0.5.1 lib/mite/time_entry.rb