wit_bot 0.4.1 → 0.4.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
  SHA1:
3
- metadata.gz: 1e387a08441a8c5f9c9b1fa391cd8ac4b5a1edb9
4
- data.tar.gz: 6d49997d4fff960c07f92ed6200cbb72814d1dc9
3
+ metadata.gz: c1b7c52f2b1b3dcb990efec623c7b8937d070863
4
+ data.tar.gz: c4fac73cffe1125374cfd876f4cbae198b2fcd00
5
5
  SHA512:
6
- metadata.gz: fa5a966a259be1ad435f06600a0b15a17b18749047625ce923192e3cceebbbb32607323df8091f20e5e069859eb79870dff82c29dfe824628bc62905600bb6a7
7
- data.tar.gz: 7d5ae281e07a6382491a7a830f9001197712576dc21152f859d57bc6b0828e6efdfbd7d713c1e16bfa4575a77bd9d053ad503e3a572960b7383f3da6b10e0717
6
+ metadata.gz: 658ca8a99ce362a44beb1d233b1df2c6ee30e1ea0fbe27d002526af4f12c8b287fd258ba060c7b2db7ef8972dede09be7b9a16457df1bc285c24da2114d8961b
7
+ data.tar.gz: 2fe302edf51fe1bde5c5e1f5d6b719b11314b83fb58771b7575a873a200729ef0ab7c0494f92f088e2a74b0605ce08c5ff07b49faa80a4cfcc1f4d4d99ee38f8
@@ -5,17 +5,19 @@ module WitBot
5
5
  def initialize(raw_entities)
6
6
  @raw = raw_entities
7
7
 
8
- super Hash[*raw_entities.map do |(role, all)|
9
- all = all.map { |data| WitModel::Entity.find(data[:entity], create: false).model role, data }
8
+ super Hash[raw_entities.map do |(role, all)|
9
+ all = all.map do |data|
10
+ entity_name = data[:entity] || role
11
+ entity = WitModel::Entity.find(entity_name, create: false)
12
+ entity.model role, data
13
+ end
10
14
 
11
- data = all.first
12
-
13
- data.all = all
15
+ data = all.length == 1 ? all.first : all
14
16
 
15
17
  create_getter role
16
18
 
17
19
  [role, data]
18
- end.flatten]
20
+ end]
19
21
  end
20
22
 
21
23
  def method_missing(*_)
@@ -1,3 +1,3 @@
1
1
  module WitBot
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wit_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben (@penne12_)