Sha256: 1b29826c8871ad6f13fa3d1f5a84a4cef467d7921cbf6eb984a03b5e27045817
Contents?: true
Size: 965 Bytes
Versions: 24
Compression:
Stored size: 965 Bytes
Contents
# frozen_string_literal: true module Katalyst module Tables module Collection # Entry point for creating a collection from an array for use with table components. class Array include Core def self.with_params(params) new.with_params(params) end def model items.first&.class || ActiveRecord::Base end def model_name @model_name ||= items.first&.model_name || ActiveModel::Name.new(Object, nil, "record") end def with_params(params) # test support params = ActionController::Parameters.new(params) unless params.is_a?(ActionController::Parameters) self.attributes = params.permit(self.class.permitted_params) self end def inspect "#<#{self.class.name} @attributes=#{attributes.inspect} @model_name=\"#{model_name}\" @count=#{items&.count}>" end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems