active_data 1.1.1 → 1.1.2
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec99c84b95cc5a79feaf4230cdbf4eb89780afc910bf03278d5f2377a48b0c5
|
4
|
+
data.tar.gz: 71941c2fd303ccca637d7f58646dc5a3e3417f506e8cee405a57649a3c770d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3603d8b5de895f35f5c19db31a1de8fa71853595a0d93cf772c2894ff0a89fec0afb1d3b3c6f56b8d410ea22339f5e9abe96ca1023a1b414b720f1526afcc09e
|
7
|
+
data.tar.gz: 35a90113764e1a5125d8cd205036e804e9dbfe7e2cb1ffdd812d6b99a5b0233c7efebafaab8452ef12d89c1a78f3d8ee212b55dd5ad59bbc8b399e80c256cbc8
|
data/CHANGELOG.md
CHANGED
data/lib/active_data/config.rb
CHANGED
@@ -2,7 +2,7 @@ module ActiveData
|
|
2
2
|
class Config
|
3
3
|
include Singleton
|
4
4
|
|
5
|
-
attr_accessor :include_root_in_json, :i18n_scope, :logger, :primary_attribute, :base_class,
|
5
|
+
attr_accessor :include_root_in_json, :i18n_scope, :logger, :primary_attribute, :base_class, :base_concern,
|
6
6
|
:_normalizers, :_typecasters
|
7
7
|
|
8
8
|
def self.delegated
|
@@ -3,22 +3,29 @@ module ActiveData
|
|
3
3
|
module Associations
|
4
4
|
module Reflections
|
5
5
|
class EmbedsAny < Base
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
class << self
|
7
|
+
def build(target, generated_methods, name, options = {}, &block)
|
8
|
+
if block
|
9
|
+
options[:class] = proc do |reflection|
|
10
|
+
superclass = reflection.options[:class_name].to_s.presence.try(:constantize)
|
11
|
+
klass = build_class(superclass)
|
12
|
+
target.const_set(name.to_s.classify, klass)
|
13
|
+
klass.class_eval(&block)
|
14
|
+
klass
|
15
15
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
end
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
private def build_class(superclass)
|
21
|
+
Class.new(superclass || ActiveData.base_class) do
|
22
|
+
include ActiveData::Model
|
23
|
+
include ActiveData::Model::Associations
|
24
|
+
include ActiveData::Model::Lifecycle
|
25
|
+
include ActiveData::Model::Primary
|
26
|
+
include ActiveData.base_concern if ActiveData.base_concern
|
19
27
|
end
|
20
28
|
end
|
21
|
-
super
|
22
29
|
end
|
23
30
|
|
24
31
|
def klass
|
data/lib/active_data/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'active_data/base'
|
3
|
+
|
4
|
+
describe ActiveData::Model::Associations::Reflections::EmbedsAny do
|
5
|
+
describe '#build' do
|
6
|
+
subject { described_class.build(User, User, :projects) {}.klass.new }
|
7
|
+
|
8
|
+
before do
|
9
|
+
stub_model(:project) do
|
10
|
+
include ActiveData::Model::Lifecycle
|
11
|
+
attribute :title, String
|
12
|
+
end
|
13
|
+
stub_model(:user) do
|
14
|
+
include ActiveData::Model::Associations
|
15
|
+
|
16
|
+
attribute :name, String
|
17
|
+
embeds_many :projects
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it { is_expected.to be_a(ActiveData::Model) }
|
22
|
+
it { is_expected.to be_a(ActiveData::Model::Primary) }
|
23
|
+
it { is_expected.to be_a(ActiveData::Model::Lifecycle) }
|
24
|
+
it { is_expected.to be_a(ActiveData::Model::Associations) }
|
25
|
+
|
26
|
+
context 'when ActiveData.base_concern is defined' do
|
27
|
+
before do
|
28
|
+
stub_const('MyModule', Module.new)
|
29
|
+
|
30
|
+
allow(ActiveData).to receive(:base_concern).and_return(MyModule)
|
31
|
+
|
32
|
+
stub_model(:user) do
|
33
|
+
include ActiveData::Model::Associations
|
34
|
+
|
35
|
+
embeds_many :projects
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it { is_expected.to be_a(MyModule) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyromaniac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -277,6 +277,7 @@ files:
|
|
277
277
|
- spec/lib/active_data/model/associations/persistence_adapters/active_record_spec.rb
|
278
278
|
- spec/lib/active_data/model/associations/references_many_spec.rb
|
279
279
|
- spec/lib/active_data/model/associations/references_one_spec.rb
|
280
|
+
- spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb
|
280
281
|
- spec/lib/active_data/model/associations/reflections/embeds_many_spec.rb
|
281
282
|
- spec/lib/active_data/model/associations/reflections/embeds_one_spec.rb
|
282
283
|
- spec/lib/active_data/model/associations/reflections/references_many_spec.rb
|
@@ -347,6 +348,7 @@ test_files:
|
|
347
348
|
- spec/lib/active_data/model/associations/persistence_adapters/active_record_spec.rb
|
348
349
|
- spec/lib/active_data/model/associations/references_many_spec.rb
|
349
350
|
- spec/lib/active_data/model/associations/references_one_spec.rb
|
351
|
+
- spec/lib/active_data/model/associations/reflections/embeds_any_spec.rb
|
350
352
|
- spec/lib/active_data/model/associations/reflections/embeds_many_spec.rb
|
351
353
|
- spec/lib/active_data/model/associations/reflections/embeds_one_spec.rb
|
352
354
|
- spec/lib/active_data/model/associations/reflections/references_many_spec.rb
|