diff --git a/lib/cantango/api_ext/macros.rb b/lib/cantango/api_ext/macros.rb index 3fe1450..2725693 100644 --- a/lib/cantango/api_ext/macros.rb +++ b/lib/cantango/api_ext/macros.rb @@ -1,7 +1,7 @@ module CanTango module Macros sweet_scope :ns => {:CanTango => 'cantango/api_ext'} do - autoload_modules :Account, :User + autoload_modules :Account, :User, :Clazz end end end diff --git a/lib/cantango/api_ext/macros/clazz.rb b/lib/cantango/api_ext/macros/clazz.rb new file mode 100644 index 0000000..f1dc9f7 --- /dev/null +++ b/lib/cantango/api_ext/macros/clazz.rb @@ -0,0 +1,15 @@ +module CanTango::Macros + module Clazz + def cantango type = nil + # determine if user or account + if !type + (name =~ /.+Account$/) ? tango_account : tango_user + else + tango_account and return if type.to_s == 'account' + tango_user 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 + alias_method :cantango_user, :tango_user + end +end \ No newline at end of file