Module: CanTango::Macros::Clazz

Includes:
Account, User
Included in:
Class
Defined in:
lib/cantango/api_ext/macros/clazz.rb

Instance Method Summary collapse

Methods included from User

#tango_user

Methods included from Account

#tango_account

Instance Method Details

#cantango(options = {}) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cantango/api_ext/macros/clazz.rb', line 6

def cantango options = {}
  type = case options
  when Array
    options.first
  when Symbol
    options
  when Hash
    options[:type]
  end
  # determine if user or account
  if !type
    (name =~ /.+Account$/) ? (options) : tango_user(options)
  else
    (options) and return if type.to_s == 'account'
    tango_user(options) and return if type.to_s == 'user'
    raise ArgumentError, "Unable to determine type of class to register; Please specify :user or :account as argument"
  end
end