Sha256: 4fec9b23eb23a58e58e77e73c6a4b673a02542ab263a60f7d43d872d602da5f9

Contents?: true

Size: 676 Bytes

Versions: 11

Compression:

Stored size: 676 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
      
      return target.keys if target.is_a? Hash

      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

11 entries across 11 versions & 1 rubygems

Version Path
table_print-1.3.3 lib/table_print/printable.rb
table_print-1.3.2 lib/table_print/printable.rb
table_print-1.3.1 lib/table_print/printable.rb
table_print-1.3.0 lib/table_print/printable.rb
table_print-1.2.0 lib/table_print/printable.rb
table_print-1.1.5 lib/table_print/printable.rb
table_print-1.1.4 lib/table_print/printable.rb
table_print-1.1.3 lib/table_print/printable.rb
table_print-1.1.2 lib/table_print/printable.rb
table_print-1.1.1 lib/table_print/printable.rb
table_print-1.1.0 lib/table_print/printable.rb