Module: SocialEngineController

Defined in:
app/controllers/social_engine_controller.rb

Instance Method Summary collapse

Instance Method Details

#able_method_name(obj) ⇒ Object



29
30
31
# File 'app/controllers/social_engine_controller.rb', line 29

def able_method_name(obj)
  "#{obj.class.to_s.underscore}able"
end

#add_able_rep(name, obj) ⇒ Object



12
13
14
15
16
17
# File 'app/controllers/social_engine_controller.rb', line 12

def add_able_rep(name,obj)
  able = able_method_name(obj)
  if obj and obj.send(able) and obj.send(able).respond_to?(:user)
    Reputation.add(name, obj.send(able).user) rescue nil
  end
end

#add_fingerprint_and_user_id(obj, save = false) ⇒ Object



4
5
6
7
8
9
10
# File 'app/controllers/social_engine_controller.rb', line 4

def add_fingerprint_and_user_id(obj,save=false)
  obj[:ip_address]=request.remote_ip
  obj[:session_hash]=request.session_options[:id]
  obj[:browser_fingerprint]=browser_fingerprint
  obj[:user_id] = current_user.id if current_user
  obj.save if save
end

#browser_fingerprintObject



19
20
21
# File 'app/controllers/social_engine_controller.rb', line 19

def browser_fingerprint
  Digest::SHA2.hexdigest(request.user_agent+request.accept+request.accept_charset+request.accept_encoding+request.accept_language) rescue nil
end

#set_polymorphic_vars(obj, able_method = nil) ⇒ Object



23
24
25
26
27
# File 'app/controllers/social_engine_controller.rb', line 23

def set_polymorphic_vars(obj,able_method=nil)
  able = able_method || able_method_name(obj)
  obj.send("#{able}_type=", request.path.split("/")[1].classify)
  obj.send("#{able}_id=", request.path.split("/")[2])
end