Skip to content

Instantly share code, notes, and snippets.

View andrewvc's full-sized avatar

Andrew Cholakian andrewvc

View GitHub Profile
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
class MyApp < DripDrop::Node
def action
route :my_server, :websocket_server, 'ws://127.0.0.1:9292'
my_server.on_open do |response|
EM::PeriodicTimer.new(1) do
my_client.send_message(:name => 'time_request') do |response_message|
puts "The time is: #{response_message.body['time']}"
end
end