class Movie < ActiveRecord::Base
  has_and_belongs_to_many :actors
  has_many :reviews, :dependent => :destroy
  belongs_to :genre
  validates_presence_of :title, 
  :message => ": A new movie must have a title (name)"
  validates_format_of :length, :with => /^[0-9][0-9]:[0-5][0-9]$/, 
  :allow_nil => true, :allow_blank => true,
  :message => "is Hours:Minutes, i.e 01:01  means one hour and 1 minute "
  
  # A METHOD TO CHECK IF A GIVEN MOVIE HAS A SPECIFIC ACTOR. 
  def has_in?(actor)
    self.actors.include?(actor)
  end  
  
  # A METHOD TO CHECK ACTORS THE MOVIE DOES NOT HAVE (OUT OF OUR COLLECTION)
  # THIS WILL FACILITATE A SELECTION LIST OF ACTORS WE CAN ADD TO THE MOVIE.
  # SET SUBTRACTION. ALL THE ACTORS MINUS THE ONES ALREADY STAFFED TO THE
  # CURRENT MOVIE (ARE POTENTIAL TO BE ADDED TO THE CURRECT MOVIE)
  def actors_not_in
    Actor.find(:all) - self.actors
  end
  
  # THIS METHOD SHOWS A MORE 'CIVILIZED' VALUE FOR BLACK AND WHITE FLAG
  def bw
    if self.black_and_white
      'Y'
    else
      'N'
    end    
  end 
    
end
