dao-gateway-active_record 1.1.0 → 1.2.0

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: 87d40ef5baf959eec23c5f6031c9be1bcaf44959
4
- data.tar.gz: 55e79ba0e99e6784c9b4283e3e86745885c96eb4
3
+ metadata.gz: c5d808e37d2bf87950af6ab7a3906e81526fcb30
4
+ data.tar.gz: 15b82b594ac5293a67647cc13cf1f7f8bfc070df
5
5
  SHA512:
6
- metadata.gz: c85da288f12e278fe12719738a11aeda9a0bf62c590666b267fb8fd9371814663527d4a42b3923e765575bfd66fdee190f7e48c5bc2d93b2b49eb627eaacc750
7
- data.tar.gz: 728a5ea93c0a7d900f07fb49c67dda01156be70b668f565dbf0db2f3d8b40c7b5d065f49aff64b0c6838e7812af31262e91f8417df6ec34e21e86278e402a740
6
+ metadata.gz: d5f75ef9ea720e015eaf1afeee28e9dfdd00a1ad7e27430d96cfba7c139eb9e4a4df5f4a9d8274b24b6c7223554cad858e86b429f8fd8fb3509e483fc99f2f41
7
+ data.tar.gz: 1d181913fb335c920a2185d512f063d45511d36ecdd9b47a1fec6347b2c5dbb25656448b112e27465ac6ea84f8a7f629c6ca7081198d91f8f14d049b1e643e1a
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.2.2'
22
22
 
23
- spec.add_dependency 'dao-gateway', '~> 1.1'
23
+ spec.add_dependency 'dao-gateway', '~> 1.2'
24
24
  spec.add_dependency 'activerecord', '>= 4.2'
25
25
  spec.add_dependency 'activesupport', '>= 4.2'
26
26
 
@@ -52,19 +52,6 @@ module Dao
52
52
  record
53
53
  end
54
54
 
55
- def import(relation, associations)
56
- @transformer.associations = associations
57
- unless relation.nil?
58
- if collection_scope?(relation)
59
- @transformer.many(relation)
60
- elsif source_scope?(relation)
61
- @transformer.one(relation)
62
- else
63
- @transformer.other(relation)
64
- end
65
- end
66
- end
67
-
68
55
  def record(domain_id)
69
56
  source.find_by_id(domain_id) if domain_id.present?
70
57
  end
@@ -73,8 +60,6 @@ module Dao
73
60
  @_relations ||= @source.reflections.keys.map(&:to_sym)
74
61
  end
75
62
 
76
- private
77
-
78
63
  def collection_scope?(relation)
79
64
  if relation.is_a?(::ActiveRecord::Relation)
80
65
  true
@@ -84,10 +69,6 @@ module Dao
84
69
  false
85
70
  end
86
71
  end
87
-
88
- def source_scope?(relation)
89
- relation.is_a?(source)
90
- end
91
72
  end
92
73
  end
93
74
  end
@@ -2,14 +2,8 @@ module Dao
2
2
  module Gateway
3
3
  module ActiveRecord
4
4
  class BaseTransformer < Dao::Gateway::ScopeTransformer
5
- def one(relation)
6
- super(Array(relation))
7
- end
8
-
9
- private
10
-
11
5
  def add_processors
12
- @processors.unshift RecordProcessor.new
6
+ pipe.preprocess(RecordProcessor.new)
13
7
  end
14
8
  end
15
9
  end
@@ -2,10 +2,12 @@ module Dao
2
2
  module Gateway
3
3
  module ActiveRecord
4
4
  class RecordProcessor < Gateway::Processor
5
- def process(record, associations, *)
6
- associations = associations.first if associations.count == 1
5
+ def prepared
6
+ @associations = @associations.first if @associations.count == 1
7
+ end
7
8
 
8
- ::HashWithIndifferentAccess.new(record.try(:serializable_hash, force_except: [], include: associations))
9
+ def process(record)
10
+ ::HashWithIndifferentAccess.new(record.try(:serializable_hash, force_except: [], include: @associations))
9
11
  end
10
12
  end
11
13
  end
@@ -1,7 +1,7 @@
1
1
  module Dao
2
2
  module Gateway
3
3
  module ActiveRecord
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dao-gateway-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - llxff
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-07-28 00:00:00.000000000 Z
12
+ date: 2016-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dao-gateway
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.1'
20
+ version: '1.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.1'
27
+ version: '1.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activerecord
30
30
  requirement: !ruby/object:Gem::Requirement