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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27e2ed440fa3be0becbf7f785d0f7bcdc40340b5
4
- data.tar.gz: a423db72c65d78f64e26a6df30b6e804bac0827f
3
+ metadata.gz: 951f4121c73328299f37e8989f790a522dba1750
4
+ data.tar.gz: 9e06a272988401c07b218b09d6e687f63d799bca
5
5
  SHA512:
6
- metadata.gz: 962983a753868c157280c1a6043564f20313a926d3d9479b9452325d3f76fb6bdad7ee3cc07f69a99053fe8862e3592582f0d78a65c02412acde366d5acadcad
7
- data.tar.gz: 05724df42d3e59948017f2f0af063880f0a03c54068acc5e29243c1b585fd118587d84dcd12e550e3047b8eda0ac0eda5c957299a8e7d85cba20545fc89e6a4f
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
- if ActiveResource::VERSION::STRING < '4.0.0'
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::BadApiResponseError unless data
40
- fail MoySklad::BadApiResponseError unless data[:data]
41
- fail MoySklad::BadApiResponseError unless data[:data]['collection']
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)
@@ -1,4 +1,5 @@
1
1
  module MoySklad
2
2
  class BaseError < RuntimeError; end
3
3
  class BadApiResponse < BaseError; end
4
+ class EmptyCollection < BaseError; end
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module MoySklad
2
- VERSION = '1.0.0.rc3'
2
+ VERSION = '1.0.0.rc4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moy_sklad
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc3
4
+ version: 1.0.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - uno4ki