Class: Mite::Base

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/mite-rb.rb

Direct Known Subclasses

Customer, Project, Service, TimeEntry, TimeEntryGroup, Tracker, User

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all(options = {}) ⇒ Object

Common shortcuts known from ActiveRecord



67
68
69
# File 'lib/mite-rb.rb', line 67

def all(options={})
  find_every(options)
end

.first(options = {}) ⇒ Object



71
72
73
# File 'lib/mite-rb.rb', line 71

def first(options={})
  find_every(options).first
end

.inherited(base) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/mite-rb.rb', line 56

def inherited(base)
  Mite.resources << base
  class << base
    attr_accessor :site_format
  end
  base.site_format = '%s'
  base.timeout = 20
  super
end

.last(options = {}) ⇒ Object



75
76
77
# File 'lib/mite-rb.rb', line 75

def last(options={})
  find_every(options).last
end

.undo_destroy(id) ⇒ Object

Undo destroy action on the resource with the ID in the id parameter.



80
81
82
# File 'lib/mite-rb.rb', line 80

def undo_destroy(id)
  returning(self.new(:id => id)) { |res| res.undo_destroy }
end

Instance Method Details

#undo_destroyObject

Undo destroy action.



86
87
88
89
90
91
92
# File 'lib/mite-rb.rb', line 86

def undo_destroy
  path = element_path(prefix_options).sub(/\.([\w]+)/, '/undo_delete.\1')
  
  returning connection.post(path, "", self.class.headers) do |response|
    load_attributes_from_response(response)
  end
end