spec/scenario.rb in walruz-rails-0.0.3 vs spec/scenario.rb in walruz-rails-0.0.4

- old
+ new

@@ -11,11 +11,11 @@ @songs = [] @colaborations = [] end def sing_the_song(song) - response = can!(:sing, song) + response = authorize(:sing, song) case response[:owner] when Colaboration authors = response[:owner].authors.dup authors.delete(self) authors.map! { |author| author.name } @@ -24,11 +24,11 @@ "I just need myself, Let's Rock! \\m/" end end def sing_with_john(song) - can!(:sing_with_john, song) + authorize(:sing_with_john, song) "Ok John, Let's Play '%s'" % song.name end JOHN = self.new("John") @@ -73,11 +73,11 @@ # end # end # # end -AuthorPolicy = Walruz::Utils.lift_subject(:author, SubjectIsActorPolicy) do |authorized, params, actor, subject| +AuthorPolicy = SubjectIsActorPolicy.for_subject(:author) do |authorized, params, actor, subject| params.merge!(:owner => actor) if authorized end class AuthorInColaborationPolicy < Walruz::Policy @@ -103,11 +103,11 @@ class Song include Walruz::Subject extend Walruz::Utils - check_authorizations :sing => orP(AuthorPolicy, AuthorInColaborationPolicy), - :sell => andP(AuthorPolicy, notP(AuthorInColaborationPolicy)), + check_authorizations :sing => any(AuthorPolicy, AuthorInColaborationPolicy), + :sell => all(AuthorPolicy, negate(AuthorInColaborationPolicy)), :sing_with_john => ColaboratingWithJohnPolicy attr_accessor :name attr_accessor :colaboration attr_accessor :author