Class: Authenticate
- Inherits:
-
MethodDecorators::Decorator
- Object
- MethodDecorators::Decorator
- Authenticate
- Defined in:
- lib/decoractors/authenticate.rb
Instance Method Summary collapse
- #call(wrapped, this, *args, &blk) ⇒ Object
- #has_roles(roles, *args, &blk) ⇒ Object
-
#initialize(authorize_function, arguments) ⇒ Authenticate
constructor
A new instance of Authenticate.
Constructor Details
#initialize(authorize_function, arguments) ⇒ Authenticate
Returns a new instance of Authenticate.
6 7 8 9 |
# File 'lib/decoractors/authenticate.rb', line 6 def initialize(, arguments) @authorize_function = @arguments = arguments end |
Instance Method Details
#call(wrapped, this, *args, &blk) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/decoractors/authenticate.rb', line 11 def call(wrapped, this, *args, &blk) puts "before authentication" puts "user #" + SecurityContextHolder.get_user() if self.send(@authorize_function, @arguments, *args, &blk) result = wrapped.call(*args, &blk) else raise CommonError::InvalidToken end puts "after authentication" result end |
#has_roles(roles, *args, &blk) ⇒ Object
24 25 26 27 |
# File 'lib/decoractors/authenticate.rb', line 24 def has_roles(roles, *args, &blk) # check roles here return true end |