realm-core 0.7.5 → 0.7.6

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: 8e6f3990f8dc36366899e3a8bbf1835bf6cf0bb880bcf13333f394b40d1075e3
4
- data.tar.gz: a03e2bb0fa656cfaada1364db1d8af4c222cbaff8cec5ffd0223629b40e11bc2
3
+ metadata.gz: bbac3dd7cbfca4bf017df5b055b50655c997b124ca5dc6d460b673cab02e1b2c
4
+ data.tar.gz: 60e1823f9b8ecd9665e6622e0c17002e24cc633c7c9ffc5c38958a06a45d597f
5
5
  SHA512:
6
- metadata.gz: 627b95689b8a4d51fb15a8665dd65be88974380c00a168f1121ae5248738140eadd82f3735ccaa0391fb33274952a9e1fe83819813b7312921b9adeb85956816
7
- data.tar.gz: ed1a34e594acb1e7f3ef3d644aecad58af6b9fdc1b436fb3ba793cdbdc131affdecf26e832b9d2997ab45501dba91bda950735e3e85bbd518cf5e7eaaea2ce7e
6
+ metadata.gz: 9e1eda055d9e1d5c1f64b908e7cbac32602945a3697afcd01eca583dd89e733c6506757671fa3a05045d2d6a3ae06fb73cfd04ada9e2022bf7c0038e4196b7aa
7
+ data.tar.gz: 4bd655af9bf12ccaf82f98a41fd1953a8f396422a175a8fb9a00c8ff30f42b089ad3390d761a2249d7a28e812ac7f187e8c80453f66820f26c8bcd08af3aad16
@@ -12,20 +12,20 @@ module Realm
12
12
 
13
13
  class << self
14
14
  def schema(*external_schemas, **attributes, &block)
15
- super(*sanitize_schemas(external_schemas, attributes), &block)
15
+ super(*sanitize_schemas(external_schemas, attributes, :schema), &block)
16
16
  end
17
17
 
18
18
  def params(*external_schemas, **attributes, &block)
19
- super(*sanitize_schemas(external_schemas, attributes), &block)
19
+ super(*sanitize_schemas(external_schemas, attributes, :params), &block)
20
20
  end
21
21
 
22
22
  def json(*external_schemas, **attributes, &block)
23
- super(*sanitize_schemas(external_schemas, attributes), &block)
23
+ super(*sanitize_schemas(external_schemas, attributes, :json), &block)
24
24
  end
25
25
 
26
26
  private
27
27
 
28
- def sanitize_schemas(things, attributes, type = :schema)
28
+ def sanitize_schemas(things, attributes, type)
29
29
  things << Realm.Struct(attributes) if attributes.present?
30
30
  things.map { |thing| convert_to_schema(thing, type) }
31
31
  end
data/lib/realm/event.rb CHANGED
@@ -37,11 +37,29 @@ module Realm
37
37
  @type ||= name.demodulize.sub('Event', '').underscore
38
38
  end
39
39
 
40
+ def flatten_attributes_meta
41
+ @flatten_attributes_meta ||= collect_attributes_meta(schema.key(:body).type)
42
+ end
43
+
40
44
  protected
41
45
 
42
46
  def body_struct(type = Dry::Core::Constants::Undefined, &block)
43
47
  attribute(:body, type, &block)
44
48
  end
49
+
50
+ private
51
+
52
+ def collect_attributes_meta(thing, path = []) # rubocop:disable Metrics/AbcSize
53
+ if thing.respond_to?(:schema) && thing.constructor_type != Dry::Types::Hash::Constructor # struct
54
+ thing.schema.keys.reduce({}) do |memo, key|
55
+ memo.merge(collect_attributes_meta(key.type, path + [key.name]))
56
+ end
57
+ elsif thing.constructor_type == Dry::Types::Array::Constructor # array
58
+ collect_attributes_meta(thing.type.member, path + [:[]])
59
+ else
60
+ thing.meta.present? ? { path => thing.meta } : {}
61
+ end
62
+ end
45
63
  end
46
64
 
47
65
  def type
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realm-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - developers@reevoo.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-15 00:00:00.000000000 Z
11
+ date: 2021-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport