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

- old
+ new

@@ -15,26 +15,34 @@ end # Each instance method simply calls the corresponding class method Authority.adjectives.each do |adjective| class_eval <<-RUBY, __FILE__, __LINE__ + 1 - def #{adjective}_by?(user) - self.class.#{adjective}_by?(user) + def #{adjective}_by?(user, options = {}) + if options.empty? + self.class.#{adjective}_by?(user) + else + self.class.#{adjective}_by?(user, options) + end end RUBY end # Each class method simply calls the `default` method Authority.adjectives.each do |adjective| class_eval <<-RUBY, __FILE__, __LINE__ + 1 - def self.#{adjective}_by?(user) - default(:#{adjective}, user) + def self.#{adjective}_by?(user, options = {}) + if options.empty? + default(:#{adjective}, user) + else + default(:#{adjective}, user, options) + end end RUBY end # Whitelisting approach: anything not specified will be forbidden - def self.default(adjective, user) + def self.default(adjective, user, options = {}) false end end