Created
July 11, 2014 15:50
-
-
Save mikecmpbll/1b0dcca88b99a6cce6f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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