lib/authority/abilities.rb in authority-2.0.1 vs lib/authority/abilities.rb in authority-2.1.0

- old
+ new

@@ -19,12 +19,16 @@ module ClassMethods Authority.adjectives.each do |adjective| class_eval <<-RUBY, __FILE__, __LINE__ + 1 - def #{adjective}_by?(user) - authorizer.#{adjective}_by?(user) + def #{adjective}_by?(user, options = {}) + if options.empty? + authorizer.#{adjective}_by?(user) + else + authorizer.#{adjective}_by?(user, options) + end end RUBY end # @return [Class] of the designated authorizer @@ -36,11 +40,15 @@ end Authority.adjectives.each do |adjective| class_eval <<-RUBY, __FILE__, __LINE__ + 1 - def #{adjective}_by?(user) - authorizer.#{adjective}_by?(user) + def #{adjective}_by?(user, options = {}) + if options.empty? + authorizer.#{adjective}_by?(user) + else + authorizer.#{adjective}_by?(user, options) + end end def authorizer self.class.authorizer.new(self) # instantiate on every check, in case model has changed end