Class: FlowdockBuildNotifier::FlowdockMessageSenderFactory
- Inherits:
-
Object
- Object
- FlowdockBuildNotifier::FlowdockMessageSenderFactory
- Defined in:
- lib/flowdock_build_notifier/flowdock_message_sender_factory.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #create_sender(email) ⇒ Object
-
#initialize(config: Configuration.load, client: Flowdock::Client.new(api_token: config.flowdock_user_token)) ⇒ FlowdockMessageSenderFactory
constructor
A new instance of FlowdockMessageSenderFactory.
- #user_by_email(email) ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(config: Configuration.load, client: Flowdock::Client.new(api_token: config.flowdock_user_token)) ⇒ FlowdockMessageSenderFactory
Returns a new instance of FlowdockMessageSenderFactory.
10 11 12 13 |
# File 'lib/flowdock_build_notifier/flowdock_message_sender_factory.rb', line 10 def initialize(config: Configuration.load, client: Flowdock::Client.new(api_token: config.flowdock_user_token)) @config = config @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/flowdock_build_notifier/flowdock_message_sender_factory.rb', line 8 def client @client end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/flowdock_build_notifier/flowdock_message_sender_factory.rb', line 8 def config @config end |
Instance Method Details
#create_sender(email) ⇒ Object
15 16 17 18 19 |
# File 'lib/flowdock_build_notifier/flowdock_message_sender_factory.rb', line 15 def create_sender(email) user = user_by_email(email) return UnknownUserSender.new(email: email, config: config) unless user PrivateMessageSender.new(user_id: user['id'], client: client) end |
#user_by_email(email) ⇒ Object
25 26 27 28 29 |
# File 'lib/flowdock_build_notifier/flowdock_message_sender_factory.rb', line 25 def user_by_email(email) @user ||= users.detect do |user| user['email'] == config.email_map[email] || user['email'] == email end end |
#users ⇒ Object
21 22 23 |
# File 'lib/flowdock_build_notifier/flowdock_message_sender_factory.rb', line 21 def users @users ||= client.get('/users') end |