Class: Helium::User

Inherits:
Resource show all
Defined in:
lib/helium/user.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#id, #params, #type

Instance Method Summary collapse

Methods inherited from Resource

#==, all, all_path, create, #created_at, #destroy, #eql?, find, #hash, initialize_from_path, #metadata, resource_name, #resource_name, singleton, #to_json, #update, #updated_at

Methods included from Utils

#datetime_to_iso, #kebab_case

Constructor Details

#initialize(opts = {}) ⇒ User

Returns a new instance of User.



6
7
8
9
10
11
12
# File 'lib/helium/user.rb', line 6

def initialize(opts = {})
  super(opts)

  @name           = @params.dig('attributes', 'name')
  @email          = @params.dig('meta', 'email')
  @pending_invite = @params.dig('meta', 'pending_invite')
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



3
4
5
# File 'lib/helium/user.rb', line 3

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/helium/user.rb', line 3

def name
  @name
end

#pending_inviteObject (readonly) Also known as: pending_invite?

Returns the value of attribute pending_invite.



3
4
5
# File 'lib/helium/user.rb', line 3

def pending_invite
  @pending_invite
end

Instance Method Details

#as_jsonObject

TODO can probably generalize this a bit more



19
20
21
22
23
24
25
# File 'lib/helium/user.rb', line 19

def as_json
  super.merge({
    name: name,
    email: email,
    pending_invite: pending_invite
  })
end

#resource_pathObject



14
15
16
# File 'lib/helium/user.rb', line 14

def resource_path
  "/user"
end