Sha256: 8b4ece41299256cf58af2c7441bd0e6722a178cd4ef464b65e9ec78a650816b8

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

module CanTango::Macros
  module Clazz
    include CanTango::Macros::Account
    include CanTango::Macros::User
    
    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(options) : tango_user(options)
      else
        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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cantango-api-0.1.3 lib/cantango/api_ext/macros/clazz.rb
cantango-api-0.1.2 lib/cantango/api_ext/macros/clazz.rb