Name
Ruby
code posted
created at 30 Jan 12:27
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
class User attr_accessor :email attr_accessor :first_name attr_accessor :last_name attr_accessor :uuid attr_accessor :is_unknown_user attr_accessor :is_deactivated attr_accessor :is_account_admin attr_accessor :is_enterprise_admin attr_accessor :account_id attr_accessor :account_enterprise_id def initialize args = {} args.each do |k,v| send("#{k}=",v) end end def self.build_from_response r attrs = {} attrs['email'] = r['email'] attrs['first_name'] = r['first_name'] attrs['last_name'] = r['last_name'] attrs['uuid'] = r['uuid'] attrs['is_unknown_user'] = r['is_unknown_user'] attrs['is_deactivated'] = r['is_deactivated'] attrs['is_account_admin'] = r['is_account_admin'] attrs['is_enterprise_admin'] = r['is_enterprise_admin'] if r['account'] attrs['account_id'] = r['account']['id'] attrs['account_enterprise_id'] = r['account']['enterprise_id'] end new(attrs) end end |
961 Bytes in 4 ms with coderay