class Object


Preliminary alternations to Kernel/Object class: Actor/Event support


Alterations to Object class: GxG::Engine dependency - quota supports

Public Instance Methods

actor?() click to toggle source
# File lib/gxg.rb, line 134
def actor?()
  false
end
alive?() click to toggle source
# File lib/gxg.rb, line 129
def alive?()
  # Why: adjusting the entire object space to dealing with possibilities introduced by Celluloid.
  true
end
handle_error(the_error={}) click to toggle source
# File lib/gxg.rb, line 138
def handle_error(the_error={})
  if the_error[:error].is_a?(::Exception)
    log_error(the_error)
  end
end
heap_used(options={}) click to toggle source
# File lib/gxg.rb, line 436
def heap_used(options={})
  unless options.is_a?(Hash)
    options={}
  end
  (self.content_size_used(options).to_i + (self.slots_used(options).to_i * GxG::Engine::profile[:slot_size]).to_i)
end
is_any?(*args) click to toggle source

public methods

# File lib/gxg.rb, line 116
def is_any?(*args)
  result = false
  args.flatten.to_enum.each do |thing|
    if thing.class == Class
      if self.is_a?(thing)
        result = true
        break
      end
    end
  end
  result
end
millisecond_latency(*args,&block) click to toggle source
# File lib/gxg.rb, line 408
def millisecond_latency(*args,&block)
  if block
    starting = Time.now.to_f
    result = block.call(*args)
    ending = Time.now.to_f
    # Results are approximate: does not include the time ruby needs to return from the call,
    # assign the result RVALUE, collect a time, convert it to a Float, and assign ending RVALUE..
    # However, it is pretty darn close.
    {:result => result, :milliseconds => (ending - starting)}
  else
    # If :milliseconds are nil then the block was not passed and since it never ran, there is no latency to count up.
    # Simply do a return_var[:milliseconds].to_f for auto-accumulators w/o post-call comparison.
    {:result => nil, :milliseconds => 0.0}
  end
  # Attribution : http://stackoverflow.com/questions/2289381/how-to-time-an-operation-in-milliseconds-in-ruby
end
serialize() click to toggle source
# File lib/gxg.rb, line 144
def serialize()
  if self.is_any?(::Array, ::Hash, ::Set, ::Struct)
    data = self.process do |entry, selector|
      entry.serialize()
    end
    begin
      ("structure:" + ::Marshal.dump(data).encode64())
    rescue Exception => the_error
      "marshal:BAgw"
    end
  else
    if self.is_a?(::String)
      if self.serialized?()
        self
      else
        ("marshal:" + ::Marshal.dump(self).encode64())
      end
    else
      # by default, or upon error, returns marshaled nil, must override to get other serialization
      begin
        ("marshal:" + ::Marshal.dump(self).encode64())
      rescue Exception => the_error
        "marshal:BAgw"
      end
    end
  end
end