Class: Ehpt::GetUserIdFromInitial

Inherits:
Base
  • Object
show all
Defined in:
lib/ehpt/get_user_id_from_initial.rb

Constant Summary collapse

@@memberships =
nil

Instance Attribute Summary collapse

Attributes inherited from Base

#data, #errors, #warnings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_error, #add_warning, call, #error?, #success?, #warning?

Constructor Details

#initialize(initial) ⇒ GetUserIdFromInitial

Returns a new instance of GetUserIdFromInitial.



15
16
17
18
# File 'lib/ehpt/get_user_id_from_initial.rb', line 15

def initialize(initial)
  @initial = initial
  super
end

Instance Attribute Details

#initialObject (readonly)

Returns the value of attribute initial.



5
6
7
# File 'lib/ehpt/get_user_id_from_initial.rb', line 5

def initial
  @initial
end

Class Method Details

.membershipsObject



7
8
9
# File 'lib/ehpt/get_user_id_from_initial.rb', line 7

def self.memberships
  @@memberships
end

.memberships=(memberships) ⇒ Object



11
12
13
# File 'lib/ehpt/get_user_id_from_initial.rb', line 11

def self.memberships=(memberships)
  @@memberships = memberships
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ehpt/get_user_id_from_initial.rb', line 20

def call
  fetch_memberships_from_pt!

  if user.nil?
    add_error("Not found any user with initial #{initial}")
  else
    @data = user.id
  end
rescue StandardError => e
  add_error(eval(e.message)[:body])
end