Module: FormatRestricterRails::Includes::ClassMethods
- Defined in:
- lib/format_restricter_rails/includes.rb
Instance Method Summary collapse
Instance Method Details
#register_before_action(options, allowed_formats) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/format_restricter_rails/includes.rb', line 18 def register_before_action(, allowed_formats) before_action() do |controller| unless allowed_formats.include?(request.format.symbol) render nothing: true, status: 406 end end end |
#restrict_formats_to(*args) ⇒ Object
12 13 14 15 16 |
# File 'lib/format_restricter_rails/includes.rb', line 12 def restrict_formats_to(*args) = args. allowed_formats = args.collect {|e| e.to_sym} register_before_action(, allowed_formats) end |