Sha256: c42b82800b74e7511a1dcc21d284fb86b41e3c1f56c7a64ca17dbc9dac7b5e00
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
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, :accept_eula, :send_invites, to: :doc VALID_TAG_REGEX = /^[A-Za-z0-9 &_'\/-]+$/ def preset=(value) self.permissions_preset = value == "custom" ? nil : value end def filter_tags=(value) unless value.is_a?(Array) raise "filter_tags= needs to be passed an Array, got #{value.class}" end doc["filter_tags"] = value.map do |tag| unless tag.match(VALID_TAG_REGEX) raise "Invalid filter tag #{tag.inspect}" end tag.upcase end 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'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecoportal-api-0.3.1 | lib/ecoportal/api/internal/account.rb |