yamlrpc 0.1.080630154212 → 0.1.080701110311

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.
@@ -13,15 +13,17 @@ module YamlRpc
13
13
 
14
14
  class Client
15
15
 
16
+ DEFAULT_FORM_DATA_ROOT = :yaml_rpc
17
+
16
18
  attr_accessor :url
17
19
  attr_accessor :form_data_root
18
20
 
19
21
  # * <tt>url</tt> Root url, ie. "http://my.com/something/"; YamlRpc#some_method(:foo => 'bar') will POST to http://my.com/something/some_method with { :foo => 'bar' } params
20
22
  # * <tt>options</tt>
21
- # * <tt>:form_data_root</tt> Default to nil; if you want all params to have single root, ie. 'yaml', set :form_data_root => :yaml
23
+ # * <tt>:form_data_root</tt> Default to :yamlrpc, meaning all params are passed inside :yamlrpc form field
22
24
  def initialize(url, options = {})
23
25
  @url = url
24
- @form_data_root = options[:form_data_root]
26
+ @form_data_root = options.has_key?(:form_data_root) ? options[:form_data_root] : DEFAULT_FORM_DATA_ROOT
25
27
  end
26
28
 
27
29
  # * <tt>method</tt> Method name
@@ -13,6 +13,7 @@ module YamlRpc
13
13
  def decode(params, fields = nil)
14
14
  r = {}
15
15
  fields = params.keys unless fields
16
+ fields = fields.is_a?(Array) ? fields : [ fields ]
16
17
  fields.each { |k| r[k] = YAML::load(params[k] || "--- \n" ) }
17
18
  r
18
19
  end
@@ -26,8 +27,10 @@ module YamlRpc
26
27
  # * <tt>params</tt> Hash
27
28
  # * <tt>fields</tt> Optional, single field name or array of field names, ie. [:foo, :bar]
28
29
  def decode_to_ary(params, fields)
30
+ r = nil
29
31
  fields = fields.is_a?(Array) ? fields : [ fields ]
30
- fields.map { |k| YAML::load(params[k] || "--- \n") }
32
+ r = fields.map { |k| YAML::load(params[k] || "--- \n") }
33
+ r.size > 1 ? r : r.first
31
34
  end
32
35
 
33
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamlrpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.080630154212
4
+ version: 0.1.080701110311
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mirek Rusin
@@ -9,7 +9,7 @@ autorequire: yamlrpc
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-30 00:00:00 +01:00
12
+ date: 2008-07-01 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15