Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:chrismccord/phoenix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Jul 4, 2014
2 parents a7a4b46 + c53066c commit b926a18
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/phoenix/socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Phoenix.Socket do
topic: nil,
router: nil,
channels: [],
assigns: []
assigns: %{}

def set_current_channel(socket, channel, topic) do
%Socket{socket | channel: channel, topic: topic}
Expand All @@ -28,6 +28,10 @@ defmodule Phoenix.Socket do
def authenticated?(socket, channel, topic) do
Enum.member? socket.channels, {channel, topic}
end

def assign(socket, key, value) do
%Socket{socket | assigns: Map.put(socket.assigns, key, value)}
end
end


1 change: 1 addition & 0 deletions lib/phoenix/statuses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed
418 Teapot
422 Unprocessable Entity
423 Locked
424 Failed Dependency
Expand Down
9 changes: 8 additions & 1 deletion test/phoenix/socket/socket_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Phoenix.Socket.SocketTest do
%Socket{pid: self,
router: nil,
channels: [],
assigns: []}
assigns: %{}}
end

test "#set_current_channel sets the current channel" do
Expand Down Expand Up @@ -47,5 +47,12 @@ defmodule Phoenix.Socket.SocketTest do
socket = Socket.delete_channel(socket, "test", "topic")
assert socket.channels == []
end

test "#assign assigns into the assigns map (yo dog)" do
socket = new_socket
assert socket.assigns == %{}
socket = Socket.assign(socket, :foo, "bar")
assert socket.assigns == %{foo: "bar"}
end
end

0 comments on commit b926a18

Please sign in to comment.