Module: AuthorizeWhen::ClassMethods

Defined in:
lib/authorize_when.rb

Instance Method Summary collapse

Instance Method Details

#authorize(options = {}, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/authorize_when.rb', line 28

def authorize(options = {}, &block)

    filter_options = {}
    filter_options[:only]   = options[:when]
    filter_options[:except] = options[:when_not]

    self.send(:before_filter, filter_options) do |controller|
      if !controller.instance_eval(&block)
        raise AuthorizeWhen::ForbiddenException
      end
    end

end