-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organises the app with libraries and settings
Signed-off-by: Akash Manohar J <[email protected]>
- Loading branch information
Showing
8 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class ActivityObserver < ActiveRecord::Observer | ||
|
||
def after_save(activity) | ||
Kandan::Config.broadcaster.broadcast(activity.attributes) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Dir["#{Rails.root}/lib/broadcasters/**/*.rb"].each do |file| | ||
require file | ||
end | ||
|
||
require "#{Rails.root}/lib/kandan_config.rb" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
######################## | ||
# Kandan settings file | ||
######################## | ||
|
||
|
||
# What should be used for broadcasting messages to browser? | ||
# valid options: Faye | ||
:broadcaster: | ||
:name: "Faye" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Broadcasters | ||
class Faye | ||
class << self | ||
def broadcast(channel, message) | ||
# NOTE FAYE_CLIENT is set in the config.ru file due to the faye bug | ||
if defined?(FAYE_CLIENT) | ||
FAYE_CLIENT.publish channel, message | ||
else | ||
puts "OOPS! FAYE_CLIENT is not defined" | ||
end | ||
end | ||
|
||
def assets | ||
["/remote/faye.js"] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Kandan | ||
class Config | ||
|
||
class << self | ||
def options | ||
@config ||= YAML.load_file "#{Rails.root}/config/kandan_settings.yml" | ||
end | ||
|
||
def broadcaster | ||
Broadcasters.const_get(Kandan::Config.options[:broadcaster][:name]) | ||
end | ||
end | ||
|
||
end | ||
end |