Archived
1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
cli-old/lib/actions/add_friend.rb
2017-08-12 02:26:11 +00:00

49 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module Actions
class AddFriend < Obredux::Thunk::Action
attr_reader :tox_client, :public_key, :text
def initialize(tox_client, public_key, text)
self.tox_client = tox_client
self.public_key = public_key
self.text = text
end
def call(dispatch)
dispatch.call Done.new tox_client.friend_add_norequest public_key
end
private
def tox_client=(value)
raise TypeError, "expected #tox_client to be a #{Tox::Client}" unless value.is_a? Tox::Client
@tox_client = value
end
def public_key=(value)
raise TypeError, "expected #public_key to be a #{Tox::PublicKey}" unless value.is_a? Tox::PublicKey
@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
def initialize(friend)
self.friend = friend
end
private
def friend=(value)
raise TypeError, "expected #friend to be a #{Tox::Friend}" unless value.is_a? Tox::Friend
@friend = value
end
end
end
end