Class: BasecampAPI::Resource

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

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.element_nameObject



174
175
176
# File 'lib/basecamp/basecamp.rb', line 174

def element_name
  name.split(/::/).last.underscore
end

.parent_resources(*parents) ⇒ Object



170
171
172
# File 'lib/basecamp/basecamp.rb', line 170

def parent_resources(*parents)
  @parent_resources = parents
end

.prefix(options = {}) ⇒ Object



186
187
188
189
190
191
192
# File 'lib/basecamp/basecamp.rb', line 186

def prefix(options = {})
  if options.any?
    options.map { |name, value| "/#{name.to_s.chomp('_id').pluralize}/#{value}" }.join + '/'
  else
    '/'
  end
end

.prefix_sourceObject



178
179
180
181
182
183
184
# File 'lib/basecamp/basecamp.rb', line 178

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