moy_sklad 1.0.0.rc3 → 1.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moy_sklad/client/collection.rb +4 -31
- data/lib/moy_sklad/error.rb +1 -0
- data/lib/moy_sklad/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 951f4121c73328299f37e8989f790a522dba1750
|
4
|
+
data.tar.gz: 9e06a272988401c07b218b09d6e687f63d799bca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6403d9d39b05b1af2c54a9cb96190976dd41b4e1ca366ab46b121b616f00c28366d4f2313ac912c02b1ff0d8dfa36c1ecc6a3e1af5edf31c8661c28e460acc17
|
7
|
+
data.tar.gz: 4b8e342a8ce8b0839d0569a65b0f50ed21f7fc718f1268aa1b77f4a0f5d1d41588cbc3d2c49bdf6e4f68f7e59de3a23d9699df04a569e9a37fcb05845f5de34f
|
@@ -5,40 +5,13 @@ require 'active_support/core_ext/hash/conversions'
|
|
5
5
|
require 'active_support/core_ext/hash/indifferent_access'
|
6
6
|
|
7
7
|
module MoySklad::Client
|
8
|
-
|
9
|
-
class Collection
|
10
|
-
include Enumerable
|
11
|
-
|
12
|
-
delegate :collect, :each, :length, :to => :to_a
|
13
|
-
|
14
|
-
attr_accessor :elements
|
15
|
-
|
16
|
-
def to_a
|
17
|
-
@elements
|
18
|
-
end
|
19
|
-
|
20
|
-
def collect!
|
21
|
-
return @elements unless block_given?
|
22
|
-
set = []
|
23
|
-
each { |o| set << yield(o) }
|
24
|
-
@elements = set
|
25
|
-
self
|
26
|
-
end
|
27
|
-
|
28
|
-
alias map! collect!
|
29
|
-
end
|
30
|
-
else
|
31
|
-
class Collection < ActiveResource::Collection
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Collection
|
8
|
+
class Collection < ActiveResource::Collection
|
36
9
|
attr_reader :metadata
|
37
10
|
|
38
11
|
def initialize(data)
|
39
|
-
fail MoySklad::
|
40
|
-
fail MoySklad::
|
41
|
-
fail MoySklad::
|
12
|
+
fail MoySklad::BadApiResponse unless data
|
13
|
+
fail MoySklad::BadApiResponse unless data[:data]
|
14
|
+
fail MoySklad::EmptyCollection unless data[:data]['collection']
|
42
15
|
|
43
16
|
@elements = data[:data]['collection'].delete(data[:object])
|
44
17
|
@elements = [@elements] if @elements.is_a?(Hash)
|
data/lib/moy_sklad/error.rb
CHANGED
data/lib/moy_sklad/version.rb
CHANGED