Sha256: 03a48fc221a2120009b1b829a8ff0c913173e7f884c3549de7da07b8ae233e06

Contents?: true

Size: 599 Bytes

Versions: 7

Compression:

Stored size: 599 Bytes

Contents

class Beatle < ActiveRecord::Base
  
  has_many :songs, :as => :author
  has_and_belongs_to_many :colaborations
  
  def sings(song)
    response = self.can?(:sing, song)
    if response[:is_colaboration?]
      colaboration = response[:colaboration]
      (other_beatles = colaboration.beatles.dup).delete(self)
      "I'll need %s to perform this properly" % other_beatles.join(', ')
    else
      'I can do this by myself!, Lets Rock \m/'
    end
  end
  
  def sell(song)
    self.can?(:sell, song)
    "Who wants the rights of '%s'?" % song.name
  end
  
  def to_s
    self.name
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
walruz-rails-0.0.11 examples/rails/app/models/beatle.rb
walruz-rails-0.0.10 examples/rails/app/models/beatle.rb
walruz-rails-0.0.9 examples/rails/app/models/beatle.rb
walruz-rails-0.0.8 examples/rails/app/models/beatle.rb
walruz-rails-0.0.3 examples/rails/app/models/beatle.rb
walruz-rails-0.0.4 examples/rails/app/models/beatle.rb
walruz-rails-0.0.5 examples/rails/app/models/beatle.rb