Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created July 11, 2014 15:50
Show Gist options
  • Save mikecmpbll/1b0dcca88b99a6cce6f2 to your computer and use it in GitHub Desktop.
Save mikecmpbll/1b0dcca88b99a6cce6f2 to your computer and use it in GitHub Desktop.
class SelectedDoorkeeperFor < DoorkeeperFor
def initialize(*args)
options = args.pop if args.last.is_a? Hash
super(options)
only(args)
end
private
def only(actions)
@filter_options[:only] = actions
end
end
class DoorkeeperForBuilder
def self.create_doorkeeper_for(foo, bar, *args)
case foo
when :all
AllDoorkeeperFor.new(bar || {})
when Hash, nil
fail InvalidSyntax
else
SelectedDoorkeeperFor.new(foo, bar, *args)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment