ar_http_wrapper 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,14 +31,14 @@ class ActiveRecordHttpWrapper
31
31
 
32
32
  def self.where(conditions)
33
33
  options = {:body => {:conditions => conditions}}
34
- get(to_path(nil,"/"), options).try(:map) { |h| _parsed(h) }
34
+ _parsed get(to_path(nil,"/"), options)
35
35
  end
36
36
 
37
37
  def self.find_each(batch_size=1000,&block)
38
38
  n_batches = (count / batch_size).to_i + 1
39
39
  n_batches.times do |i|
40
40
  options = {:body => {:offset => i * batch_size, :limit => batch_size}}
41
- records = get(to_path(nil,"/"), options).try(:map) { |h| _parsed(h) }
41
+ records = _parsed get(to_path(nil,"/"), options)
42
42
  records.each do |r|
43
43
  yield r if block_given?
44
44
  end
@@ -53,7 +53,11 @@ class ActiveRecordHttpWrapper
53
53
  private
54
54
 
55
55
  def self._parsed(to_parse)
56
- OpenStruct.new JSON.parse(to_parse.to_s).symbolize_keys
56
+ if to_parse.is_a?(Array)
57
+ to_parse.map{|_j| OpenStruct.new JSON.parse(_j.to_s).symbolize_keys}
58
+ else
59
+ OpenStruct.new JSON.parse(to_parse.to_s).try(:symbolize_keys)
60
+ end
57
61
  end
58
62
 
59
63
  def self.to_path(_id=nil,_path=nil)
@@ -1,3 +1,3 @@
1
1
  module ArHttpWrapper
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_http_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-14 00:00:00.000000000 Z
12
+ date: 2012-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails