Class: GwtRpc::Procedure

Inherits:
Object
  • Object
show all
Defined in:
lib/gwt_rpc/procedure.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, &block) ⇒ Procedure

Returns a new instance of Procedure.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/gwt_rpc/procedure.rb', line 3

def initialize(options, &block)
  options.symbolize_keys!
  @path = options[:path] or raise ":path must be provided"
  if block
    @block = block
  else
    @namespace = options[:namespace] or raise ":namespace must be provided"
    @method = options[:method] or raise ":method must be provided"
    @identifier = options[:identifier] or raise ":identifier must be provided"
  end
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



2
3
4
# File 'lib/gwt_rpc/procedure.rb', line 2

def identifier
  @identifier
end

#methodObject (readonly)

Returns the value of attribute method.



2
3
4
# File 'lib/gwt_rpc/procedure.rb', line 2

def method
  @method
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



2
3
4
# File 'lib/gwt_rpc/procedure.rb', line 2

def namespace
  @namespace
end

#pathObject (readonly)

Returns the value of attribute path.



2
3
4
# File 'lib/gwt_rpc/procedure.rb', line 2

def path
  @path
end

Instance Method Details

#call(client, *parameters) ⇒ Object



15
16
17
# File 'lib/gwt_rpc/procedure.rb', line 15

def call(client, *parameters)
  response = request(client, *parameters).call
end

#request(client, *parameters) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/gwt_rpc/procedure.rb', line 19

def request(client, *parameters)
  if @block
    GwtRpc::Request.new(client, :procedure => self, :body => @block.call(*parameters))
  else
    GwtRpc::Request.new(client, :procedure => self, :parameters => parameters)
  end
end