From 34d569f2a42a9f700561991c700702335a4efb63 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Sat, 12 Aug 2017 02:26:11 +0000 Subject: [PATCH] Add attribute Actions::AddFriend#text --- lib/actions/add_friend.rb | 10 ++++++++-- lib/main.rb | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/actions/add_friend.rb b/lib/actions/add_friend.rb index e68e94c..747eda6 100644 --- a/lib/actions/add_friend.rb +++ b/lib/actions/add_friend.rb @@ -2,11 +2,12 @@ module Actions class AddFriend < Obredux::Thunk::Action - attr_reader :tox_client, :public_key + attr_reader :tox_client, :public_key, :text - def initialize(tox_client, public_key) + def initialize(tox_client, public_key, text) self.tox_client = tox_client self.public_key = public_key + self.text = text end def call(dispatch) @@ -25,6 +26,11 @@ module Actions @public_key = value end + def text=(value) + raise TypeError, "expected #text to be a #{String}" unless value.is_a? String + @text = value + end + class Done < Obredux::Action attr_reader :friend diff --git a/lib/main.rb b/lib/main.rb index 9ebf128..1b325b9 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -87,8 +87,8 @@ private store.dispatch Actions::LoadFriends.new friends end - def on_friend_request(public_key, _text) - store.dispatch Actions::AddFriend.new @tox_client, public_key + def on_friend_request(public_key, text) + store.dispatch Actions::AddFriend.new @tox_client, public_key, text end def on_friend_message(friend, text)