lib/authority/abilities.rb in authority-0.3.0 vs lib/authority/abilities.rb in authority-0.9.0
- old
+ new
@@ -19,33 +19,27 @@
end
RUBY
end
def authorizer
- begin
- @authorizer ||= authorizer_name.constantize
- rescue StandardError => e
- if e.is_a?(NameError)
- raise Authority::NoAuthorizerError.new("#{authorizer_name} does not exist in your application")
- else
- raise e
- end
- end
+ @authorizer ||= authorizer_name.constantize
+ rescue NameError => e
+ raise Authority::NoAuthorizerError.new("#{authorizer_name} does not exist in your application")
end
end
- Authority.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?(user)
- authorizer.#{adjective}_by?(user)
- end
+ # Metaprogram needed methods, allowing for nice backtraces
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
+ def #{adjective}_by?(user)
+ authorizer.#{adjective}_by?(user)
+ end
- def authorizer
- self.class.authorizer.new(self)
- end
- RUBY
- end
+ def authorizer
+ self.class.authorizer.new(self)
+ end
+ RUBY
+ end
end
end