Assuming a PORO such as:
class Player
include ActiveModel::Model
include ActiveModel::Validations
attr_accessor :name, :position
validates :name, :position
VALID_POSITIONS = ['goalie', 'defense', 'forward']
validates :position, :inclusion { in: VALID_POSITIONS}
BENCH_WARMER = Player.new(name: "Biz", position: "bench_warmer")
end
How is
BENCH_WARMER
able to supersede the validation explicitly stated for theposition
attribute?And what does this instantiation within itself of
BENCH_WARMER
afford the application/What can I do withBENCH_WARMER
now that it exists within this class?Why validate if it's simply going to be ignored in the next line?
Googling this sort of question points to a bunch of rudimentary resources about using self
and how to create instances of an object outside of itself.