diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index bfcca135b..f0487fad5 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -174,43 +174,4 @@ module ActionController exit 1 end end -end - -module Grape - class Entity - def self.expose(*args, &block) - options = merge_options(args.last.is_a?(Hash) ? args.pop : {}) - - if args.size > 1 - fail ArgumentError, 'You may not use the :as option on multi-attribute exposures.' if options[:as] - fail ArgumentError, 'You may not use block-setting on multi-attribute exposures.' if block_given? - end - - fail ArgumentError, 'You may not use block-setting when also using format_with' if block_given? && options[:format_with].respond_to?(:call) - - options[:proc] = block if block_given? && block.parameters.any? - - @nested_attributes ||= [] - - args.each do |attribute| - unless @nested_attributes.empty? - orig_attribute = attribute.to_sym - attribute = "#{@nested_attributes.last}__#{attribute}" - nested_attribute_names_hash[attribute.to_sym] = orig_attribute - options[:nested] = true - nested_exposures_hash[@nested_attributes.last.to_sym] ||= {} - nested_exposures_hash[@nested_attributes.last.to_sym][attribute.to_sym] = options - end - - exposures[attribute.to_sym] = options - - # Nested exposures are given in a block with no parameters. - if block_given? && block.parameters.empty? - @nested_attributes << attribute - block.call - @nested_attributes.pop - end - end - end - end end \ No newline at end of file