ext_direct 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ Install as a gem:
21
21
  Then in "config/environment.rb" require middleware:
22
22
 
23
23
  config.middleware.use "ExtDirect::Router", "/direct"
24
- config.middleware.use "ExtDirect::API", "/direct_api", "/direct"
24
+ config.middleware.use "ExtDirect::API", "/api", "/direct"
25
25
 
26
26
  Great job! Now you are ready to use this library. Remember, this release is tested and runs with Rails 2.3.
27
27
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ext_direct}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcin Lewandowski"]
12
- s.date = %q{2010-06-13}
12
+ s.date = %q{2010-06-14}
13
13
  s.description = %q{The Ext Direct plugin is a simple implementation of Ext Direct router to call server-side methods on the client-side.}
14
14
  s.email = %q{marcin.martio.lewandowski@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -2,18 +2,18 @@ module ExtDirect
2
2
  module Service
3
3
  class Base
4
4
  class << self
5
- def service(name, &proc)
5
+ def service(name, params = {}, &proc)
6
6
  action = action_name_format(self.model_name)
7
7
  method = method_name_format(name)
8
- ExtDirect::Service::Provider.register(:remoting, action, method, proc)
8
+ ExtDirect::Service::Provider.register(:remoting, action, method, proc, params)
9
9
  end
10
10
 
11
11
  alias_method :remoting_service, :service
12
12
 
13
- def polling_service(name, &proc)
13
+ def polling_service(name, params = {}, &proc)
14
14
  action = action_name_format(self.model_name)
15
15
  method = method_name_format(name)
16
- ExtDirect::Service::Provider.register(:polling, action, method, proc)
16
+ ExtDirect::Service::Provider.register(:polling, action, method, proc, params)
17
17
  end
18
18
 
19
19
  private
@@ -12,8 +12,18 @@ module ExtDirect
12
12
  services.each do |action,methods|
13
13
  action = normalize_action(action)
14
14
  config['actions'][action] = []
15
- methods.each do |method,params|
16
- config['actions'][action] << {:name => normalize_method(method), :len => 1} if params[:type] == :remoting
15
+ methods.each do |method,properties|
16
+ next unless properties[:type] == :remoting
17
+
18
+ params = {}
19
+ properties[:params].each do |key,value|
20
+ params[normalize_key(key)] = value
21
+ end
22
+
23
+ config['actions'][action] << {
24
+ :name => normalize_method(method),
25
+ :len => 1
26
+ }.merge(params)
17
27
  end
18
28
  end
19
29
 
@@ -30,6 +40,10 @@ module ExtDirect
30
40
  (name.to_s)[0].chr.downcase + (camelize(name.to_s))[1..-1]
31
41
  end
32
42
 
43
+ def normalize_key(name)
44
+ normalize_method(name)
45
+ end
46
+
33
47
  def camelize(name)
34
48
  name.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
35
49
  end
@@ -4,7 +4,7 @@ module ExtDirect
4
4
  @@store = {}
5
5
 
6
6
  class << self
7
- def register(type, action, method, proc)
7
+ def register(type, action, method, proc, params = {})
8
8
  action = action.to_sym
9
9
  method = method.to_sym
10
10
 
@@ -12,6 +12,7 @@ module ExtDirect
12
12
  @@store[action][method] = {} unless @@store[action][method]
13
13
  @@store[action][method][:type] = type
14
14
  @@store[action][method][:proc] = proc
15
+ @@store[action][method][:params] = params
15
16
  end
16
17
 
17
18
  def fetch
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marcin Lewandowski
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-13 00:00:00 +02:00
17
+ date: 2010-06-14 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20