Class: Appcelerator::ServiceProc

Inherits:
Proc
  • Object
show all
Defined in:
lib/appcelerator/service.rb

Overview

Class to allow inspection and equality checking (for adding to sets) TODO: remove the to_s in eql? and hash when the singleton issue is resolved

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



253
254
255
# File 'lib/appcelerator/service.rb', line 253

def method_missing name
    eval(name.to_s, self.binding)
end

Class Method Details

.varsObject



249
250
251
# File 'lib/appcelerator/service.rb', line 249

def self.vars
    [:message_type, :service_name, :method_name, :response_type]
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


262
263
264
265
266
# File 'lib/appcelerator/service.rb', line 262

def eql?(other)
  self.class.vars.all? do |var|
    self.send(var).to_s == other.send(var).to_s
  end
end

#hashObject



269
270
271
272
273
274
275
276
# File 'lib/appcelerator/service.rb', line 269

def hash
  val = 1
  self.class.vars.each do |var|
    val << 4
    val += self.send(var).to_s.hash
  end
  val
end

#to_sObject



257
258
259
260
# File 'lib/appcelerator/service.rb', line 257

def to_s
    service = Object.const_get(service_name).instance
    "#{message_type} -> #{service.before_filters} #{service_name}.#{method_name} #{service.after_filters} -> #{response_type}"
end