playerconnect-wsdsl 0.4.1 → 0.4.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
data/lib/response.rb CHANGED
@@ -29,7 +29,7 @@ class WSDSL
29
29
  # @return [Array<WSDSL::Response::Element>]
30
30
  # @api public
31
31
  def element(opts={})
32
- el = Element.new(opts[:name], opts[:type], opts[:required])
32
+ el = Element.new(opts)
33
33
  yield(el) if block_given?
34
34
  @elements << el
35
35
  end
@@ -60,6 +60,9 @@ class WSDSL
60
60
  # @api public
61
61
  attr_reader :type
62
62
 
63
+ # @api public
64
+ attr_reader :opts
65
+
63
66
  # @return [Array<WSDSL::Response::Element::Attribute>] An array of attributes
64
67
  # @api public
65
68
  attr_reader :attributes
@@ -78,15 +81,19 @@ class WSDSL
78
81
  # param [String, Symbol] name The name of the element
79
82
  # param [String, Symbol] type The optional type of the element
80
83
  # @api public
81
- def initialize(name, type=nil, required=nil)
84
+ def initialize(opts={})
85
+ opts[:type] ||= nil
86
+ opts[:required] ||= nil
87
+
82
88
  # sets a documentation placeholder since the response doc is defined at the same time
83
89
  # the response is defined.
84
- @doc = Documentation::ElementDoc.new(name)
85
- @name = name
86
- @type = type
87
- @required = !(required==false)
90
+ @name = opts.delete(:name) if(opts.has_key?(:name))
91
+ @doc = Documentation::ElementDoc.new(@name)
92
+ @type = opts.delete(:type) if(opts.has_key?(:type))
93
+ @required = !(opts.delete(:required)==false)
88
94
  @attributes = []
89
95
  @vectors = []
96
+ @opts = opts
90
97
  # we don't need to initialize the nested elements, by default they should be nil
91
98
  end
92
99
 
@@ -172,7 +179,7 @@ class WSDSL
172
179
  # @return [Array<WSDSL::Response::Element>]
173
180
  # @api public
174
181
  def element(opts={})
175
- el = Element.new(opts[:name], opts[:type], opts[:required])
182
+ el = Element.new(opts)
176
183
  yield(el) if block_given?
177
184
  @elements ||= []
178
185
  @elements << el
@@ -237,6 +244,9 @@ class WSDSL
237
244
  # @api public
238
245
  attr_reader :obj_type
239
246
 
247
+ # @api public
248
+ attr_reader :opts
249
+
240
250
  # @api public
241
251
  attr_accessor :required
242
252
 
@@ -265,9 +275,11 @@ class WSDSL
265
275
  #
266
276
  # @api public
267
277
  def initialize(opts)
268
- @name = opts[:name]
269
- @obj_type = opts[:type]
270
- @required = !(opts[:required] == false)
278
+ opts[:required] ||= false
279
+ @name = opts.delete(:name) if opts.has_key?(:name)
280
+ @obj_type = opts.delete(:type) if opts.has_key?(:type)
281
+ @required = !(opts.delete(:required) == false)
282
+ @opts = opts
271
283
  @attributes = []
272
284
  end
273
285
 
@@ -296,7 +308,7 @@ class WSDSL
296
308
  # @return [Array<WSDSL::Response::Element>]
297
309
  # @api public
298
310
  def element(opts={})
299
- el = Element.new(opts[:name], opts[:type], opts[:required])
311
+ el = Element.new(opts)
300
312
  yield(el) if block_given?
301
313
  @elements ||= []
302
314
  @elements << el
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "playerconnect-wsdsl"
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Team SDOD"]
@@ -139,12 +139,4 @@ describe ParamsVerification do
139
139
  lambda{ ParamsVerification.validate!(params, service.defined_params) }.should raise_exception
140
140
  end
141
141
 
142
- it "should not mutate nested params to a serialized ruby object" do
143
- service = WSList.all.find{|s| s.url == "services/test_deep_nested_params"}
144
- service.should_not be_nil
145
- params = {"analytics"=>{"accountId"=>"456", "events"=>[{"eventInfo"=>"asdf", "eventInfo2"=>"asdf"}, {"eventInfo"=>"asdfasdf", "eventInfo2"=>"asdfasdf"}], "sessionId"=>"123"}}
146
- validated = ParamsVerification.validate!(params, service.defined_params)
147
- validated[:analytics][:events].should be == params['analytics']['events']
148
- end
149
-
150
142
  end
@@ -75,19 +75,6 @@ describe_service "services" do |service|
75
75
 
76
76
  end
77
77
 
78
- describe_service "services/test_deep_nested_params" do |service|
79
- service.formats :json
80
- service.http_verb :post
81
-
82
- service.params do |p|
83
- p.namespace :analytics do |a|
84
- a.string :accountId, :required => true
85
- a.string :sessionId, :required => true
86
- a.string :events, :required => true
87
- end
88
- end
89
- end
90
-
91
78
  describe_service "services/array_param" do |s|
92
79
  s.formats :xml
93
80
  s.http_verb :post
data/wsdsl.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wsdsl}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Aimonetti"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playerconnect-wsdsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: