Sha256: 57e77a3aa5accee927bb69fea63a5b6012aa2c46418fa6acd4c7790f744a554b
Contents?: true
Size: 878 Bytes
Versions: 14
Compression:
Stored size: 878 Bytes
Contents
module Godmin module Resource module Filters extend ActiveSupport::Concern included do helper_method :filter_map end def filter_map self.class.filter_map end def apply_filters(resources) if params[:filter].present? params[:filter].each do |name, value| if filter_map.key?(name.to_sym) && value.present? resources = send("filter_#{name}", resources, value) end end end resources end module ClassMethods def filter_map @filter_map ||= {} end def filter(attr, options = {}) filter_map[attr] = { as: :string, option_text: "to_s", option_value: "id", collection: nil }.merge(options) end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems