Class: WCC::Data::Nucleus::User
- Inherits:
-
Base
show all
- Defined in:
- lib/wcc/data/nucleus/user.rb
Constant Summary
collapse
- SAVE_ATTRS =
%i[arena_id rock_id user_reviewed_at]
Class Method Summary
collapse
Instance Method Summary
collapse
#new_from_response
#endpoint, #endpoint_config, #inherited, #set_endpoint
#create, #find, #list
included
Class Method Details
.search(string, options = {}) ⇒ Object
44
45
46
|
# File 'lib/wcc/data/nucleus/user.rb', line 44
def self.search(string, options={})
list(options.merge(search: string))
end
|
Instance Method Details
#address ⇒ Object
25
26
27
|
# File 'lib/wcc/data/nucleus/user.rb', line 25
def address
@address ||= Address.new self[:address].merge("user_id" => id)
end
|
21
22
23
|
# File 'lib/wcc/data/nucleus/user.rb', line 21
def contact
@contact ||= Contact.new self[:contact].merge("user_id" => id)
end
|
#save ⇒ Object
33
34
35
|
# File 'lib/wcc/data/nucleus/user.rb', line 33
def save
update_attributes saveable_attributes
end
|
#saveable_attributes ⇒ Object
37
38
39
40
41
42
|
# File 'lib/wcc/data/nucleus/user.rb', line 37
def saveable_attributes
attributes
.select { |key, _| SAVE_ATTRS.include?(key.to_sym) }
.merge(contact: contact.attributes)
.merge(address: address.attributes)
end
|
#update_attributes(attrs = {}) ⇒ Object
29
30
31
|
# File 'lib/wcc/data/nucleus/user.rb', line 29
def update_attributes(attrs={})
self.class.endpoint.update(id, user: attrs)
end
|