Sha256: 55567ea140162a3509b3051e462bcf801bc8cebba9bd5b096765c35a630c47a4
Contents?: true
Size: 847 Bytes
Versions: 3
Compression:
Stored size: 847 Bytes
Contents
require "introspection/receivers" require "metaclass" module Introspection class Snapshot attr_reader :methods def initialize(object) @methods = (object.receivers rescue []).map do |receiver| [:public, :protected, :private].map do |visibility| query_method = "#{visibility}_instance_methods" receiver.send(query_method, false).map do |method| unbound_method = receiver.instance_method(method) if unbound_method.owner.equal?(receiver) Method.new(unbound_method, visibility) end end.compact end end.flatten end def diff(other) { :added => other.methods - methods, :removed => methods - other.methods } end def changed?(other) diff(other).values.flatten.any? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
introspection-0.0.4 | lib/introspection/snapshot.rb |
introspection-0.0.3 | lib/introspection/snapshot.rb |
introspection-0.0.2 | lib/introspection/snapshot.rb |