Created
April 16, 2015 14:58
-
-
Save dgmike/afb9ab23315723623167 to your computer and use it in GitHub Desktop.
RoR: Create options actions
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
module Optionable | |
extend ActiveSupport::Concern | |
included do | |
def self.options(action, allowed) | |
send :define_method, "#{action}_options" do | |
puts "Allow: #{allowed}" | |
end | |
end | |
end | |
end | |
class PeopleController | |
include Optionable | |
options :index, "GET" | |
def index | |
# action methods | |
end | |
end | |
# [3] pry(main)> people = PeopleController.new | |
# => #<People:0x007f97cbfaa6d0> | |
# [4] pry(main)> people.index_options | |
# Allow: GET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment