Class: MingleAPI::Project

Inherits:
Base
  • Object
show all
Defined in:
lib/mingle/mingle-api.rb

Instance Method Summary collapse

Methods inherited from Base

inherited

Instance Method Details

#createObject



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(options = nil)
   self.class.element_path(self.id, options)
end

#encode(options = {}) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/mingle/mingle-api.rb', line 90

def encode(options={})
   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

Returns:

  • (Boolean)


73
74
75
76
77
78
79
80
# File 'lib/mingle/mingle-api.rb', line 73

def exists?(id, options = {})
  begin
    self.class.find(id)
    true
  rescue ActiveResource::ResourceNotFound, ActiveResource::ResourceGone
    false
  end
end

#idObject



111
112
113
# File 'lib/mingle/mingle-api.rb', line 111

def id
  @attributes['identifier']
end

#new?Boolean

Returns:

  • (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(options = {})
  Card.find(:all, :params => options.update(:identifier => id))
end