Module: CanTango::Api::UserAccount::Session
- Defined in:
- lib/cantango/api/user_account/session.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#any_account(*types) ⇒ Object
give me any logged in user or the guest user.
- #guest_account ⇒ Object
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 any_account *types types = types.flatten.select_labels.map(&:to_sym) c_account = ::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 c_account || guest_account end |
#guest_account ⇒ Object
26 27 28 |
# File 'lib/cantango/api/user_account/session.rb', line 26 def guest_account CanTango.config.guest.account end |