Posts tagged ‘hessian’

I could not find a good example of using ruby hessian api. Here is a sample code that I wrote at my work place.
Hope this helps.

require 'hessian'
class Person

@@client = Hessian::HessianClient.new('url')

class << self

    def find arg

      new(@@client.method(arg))

    end

  end

def initialize(hash)

    hash.each do |k,v|

      self.instance_variable_set("@#{k}", v)

      self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")})

      self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)})

    end

  end

end

p = Person.find('obama')