Module: CanTango::Api::UserAccount::Session

Defined in:
lib/cantango/api/user_account/session.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/cantango/api/user_account/session.rb', line 5

def self.included(base)
  ::CanTango.config.user_accounts.registered.each do |type|
    base.class_eval %{
      def session_#{type}_account
        current_#{type}_account if respond_to? :current_#{type}_account
        guest_account
      end
    }
  end
end

Instance Method Details

#any_account(*types) ⇒ Object

give me any logged in user or the guest user



17
18
19
20
21
22
23
24
# File 'lib/cantango/api/user_account/session.rb', line 17

def  *types
  types = types.flatten.select_labels.map(&:to_sym)
   = ::CanTango.config.user_accounts.registered.each do |type|
    meth = :"current_#{type}_account"
    send(meth) if respond_to?(meth) && (types.empty? || types.include?(user))
  end.compact.first
   || 
end

#guest_accountObject



26
27
28
# File 'lib/cantango/api/user_account/session.rb', line 26

def 
  CanTango.config.guest.
end