class Contentful::Management::SpaceMembership
Public Class Methods
clean_roles(roles)
click to toggle source
@private
# File lib/contentful/management/space_membership.rb, line 21 def self.clean_roles(roles) roles.map { |r| r.is_a?(Link) ? r.raw_object : r } end
create(client, space_id, attributes = {})
click to toggle source
Creates an Space
Membership
@param [Contentful::Management::Client] client @param [String] space_id @param [Hash] attributes @see _ README for full attribute list for each resource.
@return [Contentful::Management::SpaceMembership]
Calls superclass method
# File lib/contentful/management/space_membership.rb, line 42 def self.create(client, space_id, attributes = {}) super(client, space_id, nil, attributes) end
create_attributes(_client, attributes)
click to toggle source
@private
# File lib/contentful/management/space_membership.rb, line 26 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
find(client, space_id, space_membership_id)
click to toggle source
Finds an Space
Membership by ID.
@param [Contentful::Management::Client] client @param [String] space_id @param [String] space_membership_id
@return [Contentful::Management::SpaceMembership]
Calls superclass method
# File lib/contentful/management/space_membership.rb, line 53 def self.find(client, space_id, space_membership_id) super(client, space_id, nil, space_membership_id) end
Public Instance Methods
query_attributes(attributes)
click to toggle source
@private
# File lib/contentful/management/space_membership.rb, line 58 def query_attributes(attributes) { 'admin' => attributes['admin'] || attributes[:admin], 'roles' => self.class.clean_roles(attributes['roles'] || attributes[:roles]) }.reject { |_k, v| v.nil? } end
roles()
click to toggle source
Returns the list of roles for this membership.
# File lib/contentful/management/space_membership.rb, line 16 def roles (properties[:roles] || []).map { |r| r.is_a?(Link) ? r : Link.new(r, nil, client) } end