lib/avo/base_resource.rb in avo-3.0.1.beta20 vs lib/avo/base_resource.rb in avo-3.0.1.beta21

- old
+ new

@@ -262,18 +262,20 @@ end self end + VIEW_METHODS_MAPPING = { + index: [:index_fields, :display_fields], + show: [:show_fields, :display_fields], + edit: [:edit_fields, :form_fields], + update: [:edit_fields, :form_fields], + new: [:new_fields, :form_fields], + create: [:new_fields, :form_fields] + } unless defined? VIEW_METHODS_MAPPING + def fetch_fields - possible_methods_for_view = { - index: [:index_fields, :display_fields], - show: [:show_fields, :display_fields], - edit: [:edit_fields, :form_fields], - update: [:edit_fields, :form_fields], - new: [:new_fields, :form_fields], - create: [:new_fields, :form_fields] - }[view.to_sym] + possible_methods_for_view = VIEW_METHODS_MAPPING[view.to_sym] # Safe navigation operator is used because the view can be "destroy" or "preview" possible_methods_for_view&.each do |method_for_view| return send(method_for_view) if respond_to?(method_for_view) end