faye_shards 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,12 +64,12 @@ So, in my example for production I have 2 Faye instances listening to ports 4200
64
64
  == Usage
65
65
 
66
66
  URL for Faye's client-side JS (unless you store it somewhere on diff storage) is returned by this methos:
67
- FayeShards.shard(current_user.id).js_url(request.ssl?)
67
+ current_user.faye_shard.js_url(request.ssl?)
68
68
 
69
69
  Module <code>FayeShard::User::Faye</code> which can be included to your User model provides method <tt>faye_channel</tt> which returns unique channel id for user. If you do not want to include module to your model - you need to manage unique channels for users yourself.
70
70
 
71
71
  On client side, subscription should look like:
72
- client = new Faye.Client(<%= raw FayeShards.shard(current_user.id).url(request.ssl?).inspect %>);
72
+ client = new Faye.Client(<%= raw current_user.faye_shard.url(request.ssl?).inspect %>);
73
73
  fayeSubscription = client.subscribe(<%= raw current_user.faye_channel.inspect %>, function(data) {});
74
74
 
75
75
  or
@@ -79,11 +79,11 @@ or
79
79
  Pushing data to user's channel also depends on your decision to include module <code>FayeShard::User::Faye</code>. So, 2 options:
80
80
  current_user.push_to_faye(data) # Sends data to channel, returned by current_user.faye_channel
81
81
  or
82
- FayeShards.shard(1).push(my_own_method_for_channel_id, data)
82
+ FayeShards.shard(current_user.id).push(my_own_method_for_channel_id, data)
83
83
 
84
84
  Extensions can be passed as an additional hash after <tt>data</tt>
85
85
 
86
- How to push to global channel and more information about gem can be found here: TODO.
86
+ How to push to global channel and more information about gem can be found here: .
87
87
 
88
88
  == Roadmap / TODO
89
89
  * UT
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{faye_shards}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alex Kazeko"]
@@ -19,7 +19,13 @@ module FayeShard
19
19
  # * <tt>ext</tt>:: Faye extensions, eg. auth_token
20
20
  #
21
21
  def push_to_faye(data, ext = {})
22
- FayeShards.shard(self.id).push(self.faye_channel, data, ext)
22
+ faye_shard.push(self.faye_channel, data, ext)
23
+ end
24
+
25
+ # Returns shard for this user
26
+ #
27
+ def faye_shard
28
+ FayeShards.shard(self.id)
23
29
  end
24
30
 
25
31
  end
@@ -30,7 +30,7 @@ class FayeShards
30
30
  # Returns all configured shards
31
31
  #
32
32
  def all_shards
33
- @shards ||= config["shards"].map{ |shard_config| FayeShard::Shard.new(shard_config) }
33
+ @all_shards ||= config["shards"].map{ |shard_config| FayeShard::Shard.new(shard_config) }
34
34
  end
35
35
 
36
36
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faye_shards
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Kazeko