Class: IronBank::User
- Inherits:
-
Object
show all
- Extended by:
- Local, SingleForwardable
- Defined in:
- lib/iron_bank/user.rb
Overview
Constant Summary
collapse
- US_DATE_FORMAT =
"%m/%d/%Y"
- FIELDS =
[
"User ID",
"User Name",
"First Name",
"Last Name",
"Status",
"Work Email",
"Created On",
"Zuora Billing Role",
"Zuora Payment Role",
"Zuora Commerce Role",
"Zuora Platform Role",
"Zuora Finance Role",
"Zuora Reporting Role",
"Zuora Insights Role",
"Last Login"
].freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Local
all, find, find_each, first, reset_store, where
Constructor Details
#initialize(attributes) ⇒ User
Returns a new instance of User.
74
75
76
|
# File 'lib/iron_bank/user.rb', line 74
def initialize(attributes)
@attributes = attributes
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
70
71
72
|
# File 'lib/iron_bank/user.rb', line 70
def attributes
@attributes
end
|
Class Method Details
33
34
35
|
# File 'lib/iron_bank/user.rb', line 33
def all
store.values
end
|
.find(user_id) ⇒ Object
37
38
39
|
# File 'lib/iron_bank/user.rb', line 37
def find(user_id)
store[user_id] || raise(IronBank::NotFoundError, "user id: #{user_id}")
end
|
.load_records ⇒ Object
27
28
29
30
31
|
# File 'lib/iron_bank/user.rb', line 27
def load_records
CSV.foreach(users_file, headers: true).with_object({}) do |row, store|
store[row["User ID"]] = new(row.to_h.compact)
end
end
|
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/iron_bank/user.rb', line 16
def store
return {} unless users_file
@store ||= if File.exist?(users_file)
load_records
else
IronBank.logger.warn "File does not exist: #{users_file}"
{}
end
end
|
Instance Method Details
#created_on ⇒ Object
88
89
90
|
# File 'lib/iron_bank/user.rb', line 88
def created_on
@created_on ||= Date.strptime(attributes["Created On"], US_DATE_FORMAT)
end
|
78
79
80
81
82
|
# File 'lib/iron_bank/user.rb', line 78
def inspect
ruby_id = "#{self.class.name}:0x#{(object_id << 1).to_s(16)} id=\"#{id}\""
"#<#{ruby_id} user_name=\"#{user_name}\">"
end
|
#last_login ⇒ Object
84
85
86
|
# File 'lib/iron_bank/user.rb', line 84
def last_login
@last_login ||= Date.strptime(attributes["Last Login"], US_DATE_FORMAT)
end
|