lib/authority/abilities.rb in authority-0.0.1 vs lib/authority/abilities.rb in authority-0.2.0

- old
+ new

@@ -8,30 +8,34 @@ self.authorizer_name = "#{name}Authorizer" end module ClassMethods - ADJECTIVES.each do |adjective| + Authority.adjectives.each do |adjective| # Metaprogram needed methods, allowing for nice backtraces class_eval <<-RUBY, __FILE__, __LINE__ + 1 - def #{adjective}_by?(actor) - authorizer.#{adjective}_by?(actor) + def #{adjective}_by?(user) + authorizer.#{adjective}_by?(user) end RUBY end def authorizer @authorizer ||= authorizer_name.constantize end end - ADJECTIVES.each do |adjective| + Authority.adjectives.each do |adjective| # Metaprogram needed methods, allowing for nice backtraces class_eval <<-RUBY, __FILE__, __LINE__ + 1 - def #{adjective}_by?(actor) - self.class.authorizer.new(self).#{adjective}_by?(actor) + def #{adjective}_by?(user) + authorizer.#{adjective}_by?(user) + end + + def authorizer + self.class.authorizer.new(self) end RUBY end end