Class: Errbit::Cloudfuji::EventObservers::UserObserver
- Inherits:
-
Cloudfuji::EventObserver
- Object
- Cloudfuji::EventObserver
- Errbit::Cloudfuji::EventObservers::UserObserver
- Defined in:
- lib/errbit/cloudfuji/event_observers/user_observer.rb
Instance Method Summary collapse
Instance Method Details
#user_added ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/errbit/cloudfuji/event_observers/user_observer.rb', line 5 def user_added puts "Adding a new user with incoming data #{params.inspect}" puts "Devise username column: #{::Devise.cas_username_column}=" puts "Setting username to: #{params['data'].try(:[], 'ido_id')}" user = User.new(:email => params['data'].try(:[], 'email')) user.name = user.email.split('@').first user.send("#{::Devise.cas_username_column}=".to_sym, params['data'].try(:[], 'ido_id')) user.save end |
#user_removed ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/errbit/cloudfuji/event_observers/user_observer.rb', line 16 def user_removed puts "Removing user based on incoming data #{params.inspect}" puts "Devise username column: #{::Devise.cas_username_column}=" ido_id = params['data'].try(:[], 'ido_id') ido_id and User.exists?(:conditions => {::Devise.cas_username_column => ido_id}) and User.where(::Devise.cas_username_column => ido_id).destroy end |
#user_updated ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/errbit/cloudfuji/event_observers/user_observer.rb', line 27 def user_updated puts "Updating user based on incoming data #{params.inspect}" puts "Devise username column: #{::Devise.cas_username_column}=" ido_id = params['data'].try(:[], 'ido_id') if ido_id and User.exists?(:conditions => {::Devise.cas_username_column => ido_id}) user = User.where(::Devise.cas_username_column => ido_id).first user.cloudfuji_extra_attributes(params['data']) user.save end end |