Sha256: 87706e1a14e4d1fa2c6a4542eff031a277c5959897821454f4aa7ec74c564901

Contents?: true

Size: 629 Bytes

Versions: 3

Compression:

Stored size: 629 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
      
      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

3 entries across 3 versions & 1 rubygems

Version Path
table_print-1.0.1 lib/table_print/printable.rb
table_print-1.0.0 lib/table_print/printable.rb
table_print-1.0.0.rc3 lib/printable.rb