Class: MingleAPI::Project
- Defined in:
- lib/mingle/mingle-api.rb
Instance Method Summary collapse
- #create ⇒ Object
- #element_path(options = nil) ⇒ Object
- #encode(options = {}) ⇒ Object
-
#exists?(id, options = {}) ⇒ Boolean
begin monkey patches.
- #id ⇒ Object
- #new? ⇒ Boolean
-
#tickets(options = {}) ⇒ Object
end monkey patches.
Methods inherited from Base
Instance Method Details
#create ⇒ Object
98 99 100 101 102 103 |
# File 'lib/mingle/mingle-api.rb', line 98 def create connection.post(collection_path + '?' + encode, nil, self.class.headers).tap do |response| self.id = id_from_response(response) load_attributes_from_response(response) end end |
#element_path(options = nil) ⇒ Object
86 87 88 |
# File 'lib/mingle/mingle-api.rb', line 86 def element_path( = nil) self.class.element_path(self.id, ) end |
#encode(options = {}) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/mingle/mingle-api.rb', line 90 def encode(={}) val = [] attributes.each_pair do |key, value| val << "project[#{URI.escape key}]=#{URI.escape value}" rescue nil end val.join('&') end |
#exists?(id, options = {}) ⇒ Boolean
begin monkey patches
73 74 75 76 77 78 79 80 |
# File 'lib/mingle/mingle-api.rb', line 73 def exists?(id, = {}) begin self.class.find(id) true rescue ActiveResource::ResourceNotFound, ActiveResource::ResourceGone false end end |
#id ⇒ Object
111 112 113 |
# File 'lib/mingle/mingle-api.rb', line 111 def id @attributes['identifier'] end |
#new? ⇒ Boolean
82 83 84 |
# File 'lib/mingle/mingle-api.rb', line 82 def new? !self.exists?(id) end |
#tickets(options = {}) ⇒ Object
end monkey patches
107 108 109 |
# File 'lib/mingle/mingle-api.rb', line 107 def tickets( = {}) Card.find(:all, :params => .update(:identifier => id)) end |