lib/ray.rb in ruby-ray-0.3.0 vs lib/ray.rb in ruby-ray-0.4.0

- old
+ new

@@ -21,11 +21,16 @@ require_relative "ray/payloads/custom_payload" require_relative "ray/payloads/notify_payload" require_relative "ray/payloads/create_lock_payload" require_relative "ray/payloads/size_payload" require_relative "ray/payloads/json_string_payload" +require_relative "ray/payloads/caller_payload" +require_relative "ray/payloads/trace_payload" +require_relative "ray/origin/origin_factory" + + module Ray class Ray def initialize(settings, client = nil) @uuid = SecureRandom.uuid @client = client || Client.new(settings[:port], settings[:host]) @@ -115,9 +120,31 @@ send_custom payload end def class_name(anything) send_custom(anything.class.to_s, 'Class name') + end + + def caller + location = caller_locations[1] + + if (! location) + payload = Payloads::CustomPayload.new('Called at top level', 'Caller') + + send_request payload + + return self + end + + payload = Payloads::CallerPayload.new(location) + + send_request payload + end + + def trace + payload = Payloads::TracePayload.new caller_locations + + send_request payload end def to_json(*args) payloads = args.map do |arg| Payloads::JsonStringPayload.new(arg)