Class: Ecoportal::API::Internal::Person

Inherits:
V1::Person show all
Defined in:
lib/ecoportal/api/internal/person.rb

Instance Attribute Summary

Attributes inherited from Common::BaseModel

#doc

Instance Method Summary collapse

Methods inherited from V1::Person

#add_details, #details, #details=, #supervisor, #supervisor=

Methods inherited from Common::BaseModel

#as_update, build, #initialize, passthrough, #print, #to_json

Constructor Details

This class inherits a constructor from Ecoportal::API::Common::BaseModel

Instance Method Details

#accountObject



9
10
11
12
13
# File 'lib/ecoportal/api/internal/person.rb', line 9

def 
  return @account if defined?(@account)
  return @account = nil if doc["account"].nil?
  @account = Internal::Account.new(doc["account"])
end

#account=(value) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ecoportal/api/internal/person.rb', line 15

def account=(value)
  case value
  when NilClass
    doc["account"] = nil
  when Internal::Account
    doc["account"] = JSON.parse(value.to_json)
  when Hash
    # TODO
    doc["account"] = value.slice(%w[policy_group_ids landing_page_id permissions_preset permissions_custom preferences prefilter filter_tags login_provider_ids starred_ids])
  else
    # TODO
    raise "Invalid set on account: Need nil, Account or Hash; got #{value.class}"
  end
  remove_instance_variable("@account") if defined?(@account)
  return 
end

#add_accountObject



32
33
34
# File 'lib/ecoportal/api/internal/person.rb', line 32

def 
  self. = {}
end

#as_jsonObject



5
6
7
# File 'lib/ecoportal/api/internal/person.rb', line 5

def as_json
  super.update("account" => &.as_json)
end