lib/cantango/api/user/session.rb in cantango-0.8.9.4 vs lib/cantango/api/user/session.rb in cantango-0.8.9.5
- old
+ new
@@ -4,33 +4,33 @@
module Session
# Example: generated from types of accounts! (see below)
# def admin_can?(*args)
# current_ability(:admin).can?(*args)
# end
-
- def self.included(base)
+
+ def self.included(base)
::CanTango.config.users.registered.each do |user|
base.class_eval %{
def session_#{user}
current_#{user} if respond_to? :current_#{user}
guest_user
end
- }
+ }
end
- end
-
+ end
+
# give me any logged in user or the guest user
- def any_user *types
- types = types.flatten.select_labels.map(&:to_sym)
+ def any_user *types
+ types = types.flatten.select_labels.map(&:to_sym)
c_user = ::CanTango.config.users.registered.each do |user|
- send(:"current_#{user}") if respond_to?(:"current_#{user}") && (types.empty? || types.include?(user))
+ send(:"current_#{user}") if respond_to?(:"current_#{user}") && (types.empty? || types.include?(user))
end.compact.first
c_user || guest_user
- end
+ end
def guest_user
- CanTango.config.guest.user
- end
+ CanTango.config.guest.user
+ end
end
end
end
end