Module: Socrates::Adapters::StubUserDirectory

Included in:
Console, Memory
Defined in:
lib/socrates/adapters/stubs.rb

Overview

StubUserDirectory provides some simple stub behavior for adding stubbed users and querying against them. This is to be used by the stubbed versions of adapters (like Console and Memory).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#default_userObject

Returns the value of attribute default_user.



21
22
23
# File 'lib/socrates/adapters/stubs.rb', line 21

def default_user
  @default_user
end

Instance Method Details

#add_user(id: nil, name: nil, first: nil, last: nil, email: nil, tz_offset: 0) ⇒ Object

rubocop:disable Metrics/ParameterLists



28
29
30
31
32
# File 'lib/socrates/adapters/stubs.rb', line 28

def add_user(id: nil, name: nil, first: nil, last: nil, email: nil, tz_offset: 0)
  User.new(id, name, tz_offset, Profile.new(first, last, email)).tap do |new_user|
    @users << new_user
  end
end

#initializeObject



23
24
25
# File 'lib/socrates/adapters/stubs.rb', line 23

def initialize
  @users = []
end

#lookup_emailObject



43
44
45
# File 'lib/socrates/adapters/stubs.rb', line 43

def lookup_email(*)
  @default_user.profile&.email
end

#user_fromObject



39
40
41
# File 'lib/socrates/adapters/stubs.rb', line 39

def user_from(*)
  @default_user
end

#usersObject

rubocop:enable Metrics/ParameterLists



35
36
37
# File 'lib/socrates/adapters/stubs.rb', line 35

def users(*)
  @users
end