Sha256: d550786dd2a7108ce0d0f851329846586f37cd9ba0d71f3af7ed018f9f955093

Contents?: true

Size: 680 Bytes

Versions: 3

Compression:

Stored size: 680 Bytes

Contents

module Mirrors
  # The basic mirror
  class Mirror
    def initialize(obj)
      @subject = obj
    end

    def subject_id
      @subject.__id__.to_s
    end

    # A generic representation of the object under observation.
    def name
      if @subject.is_a?(String) || @subject.is_a?(Symbol)
        @subject
      else
        @subject.inspect
      end
    end

    # The equivalent to #==/#eql? for comparison of mirrors against objects
    def mirrors?(other)
      @subject == other
    end

    # Accessor to the reflected object
    def reflectee
      @subject
    end

    private

    def mirrors(list)
      list.collect { |e| Mirrors.reflect(e) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mirrors-0.0.3 lib/mirrors/mirror.rb
mirrors-0.0.2 lib/mirrors/mirror.rb
mirrors-0.0.1 lib/mirrors/mirror.rb