Class: Arkaan::Campaign
- Inherits:
-
Object
- Object
- Arkaan::Campaign
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/arkaan/campaign.rb
Overview
A campaign is a gathering of accounts playing on the same interface, and interacting in a common game.
Instance Attribute Summary collapse
-
#creator ⇒ Arkaan::Campaign
The account creating the campaign, and considered “game master”.
-
#description ⇒ String
A more detailed description, used to give further information about the campaign in general.
-
#invitations ⇒ Array<Arkaan::Campaigns::Invitation>
The invitations to players that have been made for this campaign.
-
#is_private ⇒ Boolean
TRUE if the campaign can be joined only by being invited by the creator, FALSE if it’s publicly displayed and accessible.
-
#tags ⇒ Array<String>
An array of tags describing characteristics of this campaign.
-
#title ⇒ String
The title, or name, of the campaign, used to identify it in the list.
Instance Method Summary collapse
-
#title_unicity ⇒ Object
Adds an error message if the account creating this campaign already has a campaign with the very same name.
Instance Attribute Details
#creator ⇒ Arkaan::Campaign
Returns the account creating the campaign, and considered “game master”.
26 |
# File 'lib/arkaan/campaign.rb', line 26 belongs_to :creator, class_name: 'Arkaan::Account', inverse_of: :campaigns |
#description ⇒ String
Returns a more detailed description, used to give further information about the campaign in general.
13 |
# File 'lib/arkaan/campaign.rb', line 13 field :description, type: String |
#invitations ⇒ Array<Arkaan::Campaigns::Invitation>
Returns the invitations to players that have been made for this campaign.
30 |
# File 'lib/arkaan/campaign.rb', line 30 has_many :invitations, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :campaign |
#is_private ⇒ Boolean
Returns TRUE if the campaign can be joined only by being invited by the creator, FALSE if it’s publicly displayed and accessible.
16 |
# File 'lib/arkaan/campaign.rb', line 16 field :is_private, type: Boolean, default: true |
#tags ⇒ Array<String>
Returns an array of tags describing characteristics of this campaign.
19 |
# File 'lib/arkaan/campaign.rb', line 19 field :tags, type: Array, default: [] |
#title ⇒ String
Returns the title, or name, of the campaign, used to identify it in the list.
10 |
# File 'lib/arkaan/campaign.rb', line 10 field :title, type: String |
Instance Method Details
#title_unicity ⇒ Object
Adds an error message if the account creating this campaign already has a campaign with the very same name.
39 40 41 42 43 |
# File 'lib/arkaan/campaign.rb', line 39 def title_unicity if creator? && title? && creator.campaigns.where(title: title, :id.ne => _id).exists? errors.add(:title, 'uniq') end end |