Sha256: be45534fb29284cb9c470e91e4943e61de41c005b6548af7b22d84419b9365b0
Contents?: true
Size: 850 Bytes
Versions: 1
Compression:
Stored size: 850 Bytes
Contents
module TablePrint module Printable # Sniff the data class for non-standard methods to use as a baseline for display def self.default_display_methods(target) return target.class.columns.collect(&:name) if target.class.respond_to? :columns # eg mongoid return target.fields.keys if target.respond_to? :fields and target.fields.is_a? Hash return target.keys if target.is_a? Hash return target.members.collect(&:to_sym) if target.is_a? Struct methods = [] target.methods.each do |method_name| method = target.method(method_name) if method.owner == target.class if method.arity == 0 # methods << method_name.to_s end end end methods.delete_if { |m| m[-1].chr == "!" } # don't use dangerous methods methods end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_print-1.5.0 | lib/table_print/printable.rb |