Class: Organizer::Organize

Inherits:
Object
  • Object
show all
Defined in:
lib/organizer.rb

Defined Under Namespace

Classes: APIException, MissingIdException

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/organizer.rb', line 8

def method_missing(method, *args)
  params = args[0].is_a?(Hash) ? args[0] : {}

  # raise MissingIdException.new("#{method.capitalize} id can not be empty.") unless params[:id]
  path = "#{method}/"

  if params[:id]
  	path = path + "#{params.delete(:id)}/"
  end

  Request.new(path, params)
end