Module: Socrates::Adapters::StubUserDirectory
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
-
#default_user ⇒ Object
Returns the value of attribute default_user.
Instance Method Summary collapse
-
#add_user(id: nil, name: nil, first: nil, last: nil, email: nil, tz_offset: 0) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #initialize ⇒ Object
- #lookup_email ⇒ Object
- #user_from ⇒ Object
-
#users ⇒ Object
rubocop:enable Metrics/ParameterLists.
Instance Attribute Details
#default_user ⇒ Object
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 |
#initialize ⇒ Object
23 24 25 |
# File 'lib/socrates/adapters/stubs.rb', line 23 def initialize @users = [] end |
#lookup_email ⇒ Object
43 44 45 |
# File 'lib/socrates/adapters/stubs.rb', line 43 def lookup_email(*) @default_user.profile&.email end |
#user_from ⇒ Object
39 40 41 |
# File 'lib/socrates/adapters/stubs.rb', line 39 def user_from(*) @default_user end |
#users ⇒ Object
rubocop:enable Metrics/ParameterLists
35 36 37 |
# File 'lib/socrates/adapters/stubs.rb', line 35 def users(*) @users end |