Class: Move

Inherits:
ApplicationRecord show all
Defined in:
app/models/move.rb

Overview

Actions that the hunters can take

Schema Information

Table name: moves

Indexes

index_moves_on_playbook_id  (playbook_id)

Foreign Keys

fk_rails_...  (playbook_id => playbooks.id)

Direct Known Subclasses

Moves::Basic, Moves::Descriptive, Moves::Rollable

Constant Summary collapse

MOVE_TYPES =
%w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#descriptionString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#havenBoolean

Returns:

  • (Boolean)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#idObject

Returns [].

Returns:


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#nameString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#playbook_idObject

Returns [].

Returns:


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#ratingInteger

Returns:

  • (Integer)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#seven_to_nineString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#six_and_underString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#ten_plusString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#twelve_plusString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#typeString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

#updated_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/move.rb', line 43

class Move < ApplicationRecord
  MOVE_TYPES = %w[Moves::Basic Moves::Rollable Moves::Descriptive].freeze

  belongs_to :playbook, optional: true
  has_many :hunters_moves, dependent: :destroy
  has_many :hunters, through: :hunters_moves

  scope :not_basic, -> { where.not(type: 'Moves::Basic') }
  scope :with_hunter, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters)
      .where(hunters: { id: hunter_id })
  end
  scope :include_hunter_moves, ->(hunter_id) do # rubocop:disable Style/Lambda
    includes(:hunters_moves)
      .where(hunters_moves: { hunter_id: [hunter_id, nil] })
  end
  scope :haven, -> { where(haven: true) }

  validates :type, inclusion: { in: MOVE_TYPES }
  validates :name, presence: true
  validates :description, presence: true

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  def rollable?
    false
  end

  # This is the Pundit Policy that governs Move access
  #
  # @see MovePolicy
  def self.policy_class
    MovePolicy
  end
end

Class Method Details

.policy_classObject

This is the Pundit Policy that governs Move access

See Also:


74
75
76
# File 'app/models/move.rb', line 74

def self.policy_class
  MovePolicy
end

Instance Method Details

#rollable?Boolean

Returns:

  • (Boolean)

67
68
69
# File 'app/models/move.rb', line 67

def rollable?
  false
end