Class: FayeRails::Controller
- Inherits:
-
Object
- Object
- FayeRails::Controller
- Defined in:
- lib/faye-rails/controller.rb,
lib/faye-rails/controller/channel.rb,
lib/faye-rails/controller/message.rb,
lib/faye-rails/controller/monitor.rb,
lib/faye-rails/controller/observer_factory.rb
Defined Under Namespace
Modules: ObserverFactory Classes: Channel, Message, Monitor
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
Class Method Summary collapse
-
.channel(channel, endpoint = nil, &block) ⇒ Object
Bind a number of events to a specific channel.
-
.observe(model_klass, action = :after_create, &block) ⇒ Object
Observe a model for any of the ActiveRecord::Callbacks as of v3.2.6 they are: before_validation after_validation before_save before_create after_create after_save after_commit api.rubyonrails.org/classes/ActiveRecord/Callbacks.html action defaults to after_create.
- .publish(channel, message, endpoint = nil) ⇒ Object
Instance Method Summary collapse
- #channel(channel, endpoint = nil, &block) ⇒ Object
- #observe(model_klass, action = :after_create, &block) ⇒ Object
- #publish(channel, message, endpoint = nil) ⇒ Object
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
8 9 10 |
# File 'lib/faye-rails/controller.rb', line 8 def channels @channels end |
Class Method Details
.channel(channel, endpoint = nil, &block) ⇒ Object
Bind a number of events to a specific channel.
32 33 34 35 36 |
# File 'lib/faye-rails/controller.rb', line 32 def self.channel(channel, endpoint=nil, &block) channel = Channel.new(channel, endpoint) channel.instance_eval(&block) (@channels ||= []) << channel end |
.observe(model_klass, action = :after_create, &block) ⇒ Object
Observe a model for any of the ActiveRecord::Callbacks as of v3.2.6 they are: before_validation after_validation before_save before_create after_create after_save after_commit api.rubyonrails.org/classes/ActiveRecord/Callbacks.html action defaults to after_create
21 22 23 24 |
# File 'lib/faye-rails/controller.rb', line 21 def self.observe(model_klass, action = :after_create, &block) # Dynamically create a new observe class ObserverFactory.define(model_klass, action, &block) end |
Instance Method Details
#channel(channel, endpoint = nil, &block) ⇒ Object
38 39 40 41 42 |
# File 'lib/faye-rails/controller.rb', line 38 def channel(channel, endpoint=nil, &block) channel = Channel.new(channel, endpoint) channel.instance_eval(&block) (@channels ||= []) << channel end |
#observe(model_klass, action = :after_create, &block) ⇒ Object
26 27 28 29 |
# File 'lib/faye-rails/controller.rb', line 26 def observe(model_klass, action = :after_create, &block) # Dynamically create a new observe class ObserverFactory.define(model_klass, action, &block) end |
#publish(channel, message, endpoint = nil) ⇒ Object
48 49 50 |
# File 'lib/faye-rails/controller.rb', line 48 def publish(channel, , endpoint=nil) self.class.publish(channel, , endpoint) end |