Sha256: a3e1266227e302d54f0f4c8f743c3f8696fe4e2e7296e29bdb54ccd334429bbf

Contents?: true

Size: 473 Bytes

Versions: 22

Compression:

Stored size: 473 Bytes

Contents

module Trestle
  class Display
    def initialize(instance)
      @instance = instance
    end

    def to_s
      if display_method != :to_s || @instance.method(display_method).source_location
        @instance.public_send(display_method)
      else
        "#{@instance.class} (##{@instance.id})"
      end
    end

  private
    def display_method
      @display_method ||= Trestle.config.display_methods.find { |m| @instance.respond_to?(m) } || :to_s
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
trestle-0.10.1 lib/trestle/display.rb
trestle-0.10.0 lib/trestle/display.rb
trestle-0.10.0.pre2 lib/trestle/display.rb
trestle-0.10.0.pre lib/trestle/display.rb
trestle-0.9.8 lib/trestle/display.rb
trestle-0.9.7 lib/trestle/display.rb
trestle-0.9.6 lib/trestle/display.rb
trestle-0.9.5 lib/trestle/display.rb
trestle-0.9.4 lib/trestle/display.rb
trestle-0.9.3 lib/trestle/display.rb
trestle-0.9.2 lib/trestle/display.rb
trestle-0.9.1 lib/trestle/display.rb
trestle-0.9.0 lib/trestle/display.rb
trestle-0.8.13 lib/trestle/display.rb
trestle-0.8.12 lib/trestle/display.rb
trestle-0.8.11 lib/trestle/display.rb
trestle-0.8.10 lib/trestle/display.rb
trestle-0.8.9 lib/trestle/display.rb
trestle-0.8.8 lib/trestle/display.rb
trestle-0.8.7 lib/trestle/display.rb