arkaan 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arkaan/campaign.rb +12 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fef3f8545681fb10e24aed9eb6c62b0bab66da74
4
- data.tar.gz: 642c8861fa417116ec20ac75215ca2d5594685d5
3
+ metadata.gz: fa9c1beeceeeeea892222da50ff76cdda7292972
4
+ data.tar.gz: dba53cfc47a60fadf5b6aee7eef2884145ac8f41
5
5
  SHA512:
6
- metadata.gz: e2c0e2500ccfb9613b3f848acb31fba6be675a26a1f3d4d6e58b6200ac39c6666f68d1629b9d5d70645eb7c13b45f2ed1325af48376b68f6c6e8236b774c092e
7
- data.tar.gz: a18579f1be89115fd0391bd4de4003e0bff8b60b21f0ad89d660de713c6de6e1257da091429578bb958ac85463114cb49e583caeebb62180743e419412cea2e7
6
+ metadata.gz: a4a9fc2e8f4630bff017da345762e96c332eee15f1b7bc6abcf6a8341f64a95cc11fd1e94dba38b407ab6b80cac84965c3b4b76bf97524accc3b4b02a5cb38de
7
+ data.tar.gz: 9c1942f2c13da935500be2a856b60f0a56dbb36e849bb2fd0a24ac3cac968626124049ea8caa8f66d65de4f30d26e8a96f650f880b047beb2cdbfdafdf5a669d
@@ -39,11 +39,10 @@ module Arkaan
39
39
  validates :max_players,
40
40
  numericality: {less_than: 21, message: 'maximum'}
41
41
 
42
- validates :max_players,
43
- numericality: {greater_than: 0, message: 'minimum'}
44
-
45
42
  validate :title_unicity
46
43
 
44
+ validate :max_players_minimum
45
+
47
46
  # Sets the creator of the campaign. This method is mainly used for backward-compatibility needs.
48
47
  # @param account [Arkaan::Account] the account of the creator for this campaign.
49
48
  def creator=(account)
@@ -68,5 +67,15 @@ module Arkaan
68
67
  errors.add(:title, 'uniq')
69
68
  end
70
69
  end
70
+
71
+ def max_players_minimum
72
+ if max_players? && (max_players < players_count || max_players < 1)
73
+ errors.add(:max_players, 'minimum')
74
+ end
75
+ end
76
+
77
+ def players_count
78
+ invitations.where(enum_status: :accepted).count
79
+ end
71
80
  end
72
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arkaan
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-20 00:00:00.000000000 Z
11
+ date: 2018-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec