Class: Harbinger::Reporters::UserReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/harbinger/reporters/user_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, config = {}) ⇒ UserReporter

Returns a new instance of UserReporter.



6
7
8
9
# File 'lib/harbinger/reporters/user_reporter.rb', line 6

def initialize(user, config = {})
  @user = user
  @method_names = config.fetch(:method_names) { ['username'] }
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



3
4
5
# File 'lib/harbinger/reporters/user_reporter.rb', line 3

def user
  @user
end

Instance Method Details

#accept(message) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/harbinger/reporters/user_reporter.rb', line 11

def accept(message)
  method_names.each do |method_name|
    if user.respond_to?(method_name)
      message.append('user', method_name, user.public_send(method_name))
    end
  end
end