lib/cantango/api_ext/macros/clazz.rb in cantango-api-0.1.1 vs lib/cantango/api_ext/macros/clazz.rb in cantango-api-0.1.2

- old
+ new

@@ -1,16 +1,24 @@ module CanTango::Macros module Clazz include CanTango::Macros::Account include CanTango::Macros::User - def cantango type = nil + 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$/) ? tango_account : tango_user + (name =~ /.+Account$/) ? tango_account(options) : tango_user(options) else - tango_account and return if type.to_s == 'account' - tango_user and return if type.to_s == 'user' + tango_account(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 end end \ No newline at end of file