module Ecoportal module API class Internal class Account < Common::BaseModel passthrough :policy_group_ids, :landing_page_id, :permissions_preset, :permissions_custom, :preferences, :prefilter, :filter_tags, :login_provider_ids, :starred_ids, to: :doc def preset=(value) self.permissions_preset = value == "custom" ? nil : value end def preset self.permissions_preset.nil? ? "custom" : self.permissions_preset end def as_json super.tap do |hash| if preset == "custom" hash["permissions_custom"] = permissions.as_json else hash.delete "permissions_custom" end hash["preferences"] = preferences.as_json end end def permissions return @permissions if defined?(@permissions) doc["permissions_custom"] ||= {} @permissions = Internal::Permissions.new(doc["permissions_custom"]) end def preferences return @preferences if defined?(@preferences) doc["preferences"] ||= {} @preferences = Internal::Preferences.new(doc["preferences"]) end end end end end require 'ecoportal/api/internal/permissions' require 'ecoportal/api/internal/preferences'