Class: Ecoportal::API::Internal::Account
- Inherits:
-
Common::BaseModel
- Object
- Common::BaseModel
- Ecoportal::API::Internal::Account
- Defined in:
- lib/ecoportal/api/internal/account.rb
Instance Attribute Summary
Attributes inherited from Common::BaseModel
Instance Method Summary collapse
- #as_json ⇒ Object
-
#login_provider_ids ⇒ Array<String>
The login provider ids of this user.
-
#permissions_custom=(value) ⇒ Object
It preserves the values of keys that are not defined in
value. -
#policy_group_ids ⇒ Array<String>
The policy group ids of this user.
-
#policy_group_ids=(value) ⇒ Object
Sets the
policy_group_ids. -
#preferences=(value) ⇒ Object
It preserves the values of keys that are not defined in
value. -
#preset ⇒ nil, String
Gets the
permissions_preset. -
#preset=(value) ⇒ Object
Sets the
permissions_preset. -
#starred_ids ⇒ Array<String>
The starred page ids of this user.
Methods inherited from Common::BaseModel
#as_update, #consolidate!, #dirty?, #doc, embeds_one, #initial_doc, #initialize, #original_doc, passthrough, #pretty_print, #reset!, #to_json
Methods included from Common::BaseClass
#class_resolver, #resolve_class
Constructor Details
This class inherits a constructor from Ecoportal::API::Common::BaseModel
Instance Method Details
#as_json ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ecoportal/api/internal/account.rb', line 72 def as_json super.tap do |hash| if preset == "custom" hash["permissions_custom"] = .as_json else hash.delete "permissions_custom" end hash["preferences"] = preferences.as_json end end |
#login_provider_ids ⇒ Array<String>
Returns the login provider ids of this user.
35 36 37 |
# File 'lib/ecoportal/api/internal/account.rb', line 35 def login_provider_ids doc["login_provider_ids"] ||= [] end |
#permissions_custom=(value) ⇒ Object
It preserves the values of keys that are not defined in value.
60 61 62 63 |
# File 'lib/ecoportal/api/internal/account.rb', line 60 def (value) doc["permissions_custom"] ||= {} doc["permissions_custom"].merge!(value) end |
#policy_group_ids ⇒ Array<String>
Returns the policy group ids of this user.
30 31 32 |
# File 'lib/ecoportal/api/internal/account.rb', line 30 def policy_group_ids doc["policy_group_ids"] ||= [] end |
#policy_group_ids=(value) ⇒ Object
it preserves the original order
Sets the policy_group_ids
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ecoportal/api/internal/account.rb', line 18 def policy_group_ids=(value) unless value.is_a?(Array) raise "policy_group_ids= needs to be passed an Array, got #{value.class}" end value.uniq! ini_ids = (original_doc && original_doc["policy_group_ids"]) || [] # preserve original order to avoid false updates doc["policy_group_ids"] = (ini_ids & value) + (value - ini_ids) end |
#preferences=(value) ⇒ Object
It preserves the values of keys that are not defined in value.
67 68 69 70 |
# File 'lib/ecoportal/api/internal/account.rb', line 67 def preferences=(value) doc["preferences"] ||= {} doc["preferences"].merge!(value) end |
#preset ⇒ nil, String
basically the same as permissions_preset but when 'nil', it returns "custom" instead
Gets the permissions_preset.
54 55 56 |
# File 'lib/ecoportal/api/internal/account.rb', line 54 def preset self..nil? ? "custom" : self. end |
#preset=(value) ⇒ Object
basically the same as permissions_preset= but when "custom", it's changed to nil
Sets the permissions_preset.
47 48 49 |
# File 'lib/ecoportal/api/internal/account.rb', line 47 def preset=(value) self. = value == "custom" ? nil : value end |
#starred_ids ⇒ Array<String>
Returns the starred page ids of this user.
40 41 42 |
# File 'lib/ecoportal/api/internal/account.rb', line 40 def starred_ids doc["starred_ids"] ||= [] end |