class Doorkeeper::DoorkeeperFor

def filter_options

def filter_options
  @filter_options
end

def if(if_block)

def if(if_block)
  @filter_options[:if] = if_block
end

def initialize(options)

def initialize(options)
  options ||= {}
  raise InvalidSyntax unless options.is_a? Hash
  @filter_options = {}
  options.each do |k, v|
    self.send(k, v)
  end
end

def scopes(scopes)

def scopes(scopes)
  @scopes = scopes
end

def unless(unless_block)

def unless(unless_block)
  @filter_options[:unless] = unless_block
end

def validate_token(token)

TODO: move this to Token class
def validate_token(token)
  return false unless token
  token.accessible? and validate_token_scopes(token)
end

def validate_token_scopes(token)

TODO: move this to Token class
def validate_token_scopes(token)
  return true if @scopes.blank?
  token.scopes.any? { |scope| @scopes.include? scope}
end