Skip to content

Commit

Permalink
element_path modified
Browse files Browse the repository at this point in the history
  • Loading branch information
ana-ci committed Jan 4, 2011
1 parent 7bd20d7 commit 96231c5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/codaset/codaset-api.rb
Expand Up @@ -84,6 +84,7 @@ def resources


class Base < ActiveResource::Base
self.format = :json
self.site = 'https://api.codaset.com'
def self.inherited(base)
CodasetAPI.resources << base
Expand All @@ -93,12 +94,13 @@ class << base
base.site_format = '%s'
super
end

end

# Find projects
#
# CodasetAPI::Project.find(:all) # find all projects for the current account.
# CodasetAPI::Project.find(44) # find individual project by ID
# CodasetAPI::Project.find('my-project') # find individual project by slug
#
# Creating a Project
#
Expand All @@ -109,20 +111,26 @@ class << base
#
# Updating a Project
#
# project = CodasetAPI::Project.find(44)
# project = CodasetAPI::Project.find('my-project')
# project.name = "Codaset Issues"
# project.public = false
# project.save
#
# Finding tickets
#
# project = CodasetAPI::Project.find(44)
# project = CodasetAPI::Project.find('my-project')
# project.tickets
#

class Project < Base

def self.element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}/#{id}/#{query_string(query_options)}"
end

def tickets(options = {})
Ticket.find(:all, :params => options.update(:slug => id))
Ticket.find(:all, :params => options.update(:slug => slug))
end
end

Expand All @@ -140,7 +148,7 @@ def tickets(options = {})
#

class Ticket < Base
self.site += '/:project_slug/'
self.site += '/:slug/tickets/'
end

end

0 comments on commit 96231c5

Please sign in to comment.