Class: Asana::Resource

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/asana/resource.rb

Direct Known Subclasses

Project, Story, Tag, Task, User, Workspace

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.check_prefix_options(options) ⇒ Object



5
6
# File 'lib/asana/resource.rb', line 5

def check_prefix_options(options)
end

.custom_method_collection_url(method_name, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/asana/resource.rb', line 8

def custom_method_collection_url(method_name, options = {})
  prefix_options, query_options = split_options(options)
  if method_name
    "#{prefix(prefix_options)}#{collection_name}/#{method_name}.#{format.extension}#{query_string(query_options)}"
  else
    "#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
  end
end

.parent_resources(*resources) ⇒ Object



17
18
19
# File 'lib/asana/resource.rb', line 17

def parent_resources(*resources)
  @parent_resources = resources
end

.prefix(options = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/asana/resource.rb', line 21

def prefix(options = {})
  if options.any?
    self.site.path + options.map { |k, v| "#{k.to_s.chomp('_id').pluralize}/#{v}" }.join + '/'
  else
    self.site.path
  end
end

.prefix_optionsObject



29
30
31
# File 'lib/asana/resource.rb', line 29

def prefix_options
  id ? {} : super
end

.prefix_sourceObject



33
34
35
36
37
38
39
# File 'lib/asana/resource.rb', line 33

def prefix_source
  if @parent_resources
    self.site.path + @parent_resources.map { |r| "#{r.to_s.pluralize}/:#{r}_id" }.join + '/'
  else
    self.site.path
  end
end

Instance Method Details

#method_not_allowedObject

Raises:

  • (ActiveResource::MethodNotAllowed)


43
44
45
# File 'lib/asana/resource.rb', line 43

def method_not_allowed
  raise ActiveResource::MethodNotAllowed.new(__method__)
end

#to_json(options = {}) ⇒ Object



47
48
49
# File 'lib/asana/resource.rb', line 47

def to_json(options={})
  super({ :root => 'data' }.merge(options))
end