Class: Arkaan::Campaigns::Invitation

Inherits:
Object
  • Object
show all
Includes:
Arkaan::Concerns::Enumerable, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/arkaan/campaigns/invitation.rb

Overview

An invitation is the linked between a player and a campaign, accepted or not.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountArkaan::Account

Returns the account the invitation has been issued to.

Returns:



16
# File 'lib/arkaan/campaigns/invitation.rb', line 16

belongs_to :account, class_name: 'Arkaan::Account', inverse_of: :invitations

#campaignArkaan::Campaign

Returns the campaign the invitation has been made in.

Returns:



19
# File 'lib/arkaan/campaigns/invitation.rb', line 19

belongs_to :campaign, class_name: 'Arkaan::Campaign', inverse_of: :invitations

#charactersArray<Arkaan::Campaigns::Character>

Returns the character sheets for this player.

Returns:



26
# File 'lib/arkaan/campaigns/invitation.rb', line 26

has_many :characters, class_name: 'Arkaan::Campaigns::Character', inverse_of: :invitation

#filesArray<Arkaan::Campaigns::Files::Document>

Returns the files uploaded in this campaign by the user linked to this invitation.

Returns:



23
# File 'lib/arkaan/campaigns/invitation.rb', line 23

has_many :permissions, class_name: 'Arkaan::Campaigns::Files::Permission', inverse_of: :invitation

#statusSymbol

Returns the current status of the invitation.

Returns:

  • (Symbol)

    the current status of the invitation.



12
# File 'lib/arkaan/campaigns/invitation.rb', line 12

enum_field :status, [:accepted, :blocked, :expelled, :ignored, :left, :pending, :refused, :request, :creator], default: :pending

Instance Method Details

#characterArkaan::Campaigns::Files::Character

Gets the currently selected character in a convenient way.

Returns:

  • (Arkaan::Campaigns::Files::Character)

    the character currently selected by the player.



30
31
32
# File 'lib/arkaan/campaigns/invitation.rb', line 30

def character
  characters.where(selected: true).first
end

#documentsObject



34
35
36
# File 'lib/arkaan/campaigns/invitation.rb', line 34

def documents
  permissions.map(&:document)
end

#has_file?(filename) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/arkaan/campaigns/invitation.rb', line 38

def has_file?(filename)
  return permissions.map(&:document).map(&:name).any? do |name|
    name == filename
  end
end