Sha256: 5254a6d199fa064c920fe27698189c79b78b321e6816d3376d40d68352f6df59
Contents?: true
Size: 1.27 KB
Versions: 8
Compression:
Stored size: 1.27 KB
Contents
require_relative 'resource' module Contentful module Management # Resource class for Space Membership. class SpaceMembership include Contentful::Management::Resource include Contentful::Management::Resource::Refresher include Contentful::Management::Resource::SystemProperties property :user, Link property :roles, :array property :admin, :boolean # Returns the list of roles for this membership. def roles (properties[:roles] || []).map { |r| r.is_a?(Link) ? r : Link.new(r, nil, client) } end # @private def self.clean_roles(roles) roles.map { |r| r.is_a?(Link) ? r.raw_object : r } end # @private def self.create_attributes(_client, attributes) { 'admin' => attributes['admin'] || attributes.fetch(:admin), 'roles' => clean_roles(attributes['roles'] || attributes.fetch(:roles)), 'email' => attributes['email'] || attributes.fetch(:email) } end # @private def query_attributes(attributes) { 'admin' => attributes['admin'] || attributes[:admin], 'roles' => self.class.clean_roles(attributes['roles'] || attributes[:roles]) }.reject { |_k, v| v.nil? } end end end end
Version data entries
8 entries across 8 versions & 1 rubygems