Class: Faye::Channel
- Inherits:
-
Object
show all
- Includes:
- Publisher
- Defined in:
- lib/faye/protocol/channel.rb
Defined Under Namespace
Classes: Tree
Constant Summary
collapse
- HANDSHAKE =
'/meta/handshake'
- CONNECT =
'/meta/connect'
- SUBSCRIBE =
'/meta/subscribe'
- UNSUBSCRIBE =
'/meta/unsubscribe'
- DISCONNECT =
'/meta/disconnect'
- META =
:meta
- SERVICE =
:service
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Publisher
#add_subscriber, #count_subscribers, #publish_event, #remove_subscriber
Constructor Details
#initialize(name) ⇒ Channel
Returns a new instance of Channel.
7
8
9
|
# File 'lib/faye/protocol/channel.rb', line 7
def initialize(name)
@name = name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/faye/protocol/channel.rb', line 5
def name
@name
end
|
Class Method Details
39
40
41
42
|
# File 'lib/faye/protocol/channel.rb', line 39
def meta?(name)
segments = parse(name)
segments ? (segments.first == META) : nil
end
|
.parse(name) ⇒ Object
34
35
36
37
|
# File 'lib/faye/protocol/channel.rb', line 34
def parse(name)
return nil unless valid?(name)
name.split('/')[1..-1].map { |s| s.to_sym }
end
|
.service?(name) ⇒ Boolean
44
45
46
47
|
# File 'lib/faye/protocol/channel.rb', line 44
def service?(name)
segments = parse(name)
segments ? (segments.first == SERVICE) : nil
end
|
.subscribable?(name) ⇒ Boolean
49
50
51
52
|
# File 'lib/faye/protocol/channel.rb', line 49
def subscribable?(name)
return nil unless valid?(name)
not meta?(name) and not service?(name)
end
|
Instance Method Details
#<<(message) ⇒ Object
11
12
13
|
# File 'lib/faye/protocol/channel.rb', line 11
def <<(message)
publish_event(:message, message)
end
|
#unused? ⇒ Boolean
15
16
17
|
# File 'lib/faye/protocol/channel.rb', line 15
def unused?
count_subscribers(:message).zero?
end
|