mumukit-service 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjUzNWYzMTYyZDdhOTJiNTlhZWQwYmZjNWUyOGY0NDdmZDkwYTYzNQ==
4
+ MDZhZThmNzUwMzEzMmI1OTYzYmU4YmNhNzQwZjlhYjA4MDg3Njg3Yw==
5
5
  data.tar.gz: !binary |-
6
- NDA3MmQ5OTU1ZGM1NjFkOWNkZTRiY2Q5YmZkYzg2MGUwYjE0YjRlMg==
6
+ MGEwYzc2MzY3ZGZhMmUzZWYyZGQ1MTM3NDNlOTg2YWI5OGY5YWZhMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmVlNjY3YzAyNjZhMTEyOTc5ODdhNGZlMGRlMGJhN2FkNDM1YjY2MTUxNWI1
10
- NjEyNzY3M2YxOWI2ZjEyNGFjZTc0OTQ3M2I2NDBjYmY5Nzg5MGQ1M2JjZTBm
11
- M2Y2M2Y0ZDZjYzgxNzAyOGE5YzY4NmJlNWMyYzkxNGFmZTQ4ZGI=
9
+ ZmRjNDcyMjk4ZGI5MGNmNTJjNTFjMmIwNTE0MzIzYWRmYTllMmNlOWI5MGE1
10
+ NmQxMDc0Yzg0MjlmNmQ4OTI0MmU1Y2I4YjNiNWU3N2FmZTc4ODhjODRhMzgy
11
+ Y2I2M2Y0NTE3MTZiYTVmODVlZDBlY2Q2MjEyNTFmYmU2NTY1YjM=
12
12
  data.tar.gz: !binary |-
13
- OTNhMDZiZGE5OWY1YTA2NGM0Nzk5OTJhMTQyZmQwYjg1N2I4MzAzYzdkN2Yw
14
- YmE3YmFkYWNkNGM4NWZhYmY0MzJhN2U0MjNkNGU4NTMzMGI0OTY3NWRhNDI2
15
- ODkwOWJkYmYxODE1MGUzZGZkNjhmZmU1NmNlNmQ3NzAzYjhlMmQ=
13
+ YzE4YzBkOTcyNDUwNzk0YTA2MmY1YTA3NTQzYTgwN2FiYzc0NzI2NjJjZjJh
14
+ ZGYxYjRlNGRiNDQxMDMzNWU4OGYxYWYwMDQxODJiZGNmMGY3NGU2ZjQ3YzM0
15
+ YTQ3YjdiMjM3OGJhMWU0N2E3ODI1OGZhMDJlM2JiOTE1YTNmYzk=
@@ -83,6 +83,13 @@ module Mumukit::Service
83
83
  wrap_array raw
84
84
  end
85
85
 
86
+ def migrate!(query={})
87
+ where(query).each do |document|
88
+ yield document
89
+ upsert_by! :id, document
90
+ end
91
+ end
92
+
86
93
  private
87
94
 
88
95
  def validate_presence(args, first)
@@ -1,6 +1,7 @@
1
1
  module Mumukit::Service
2
2
  class Document
3
3
  attr_accessor :raw
4
+ delegate :[], to: :json
4
5
 
5
6
  def initialize(json)
6
7
  @raw = json.to_h.symbolize_keys
@@ -10,12 +11,19 @@ module Mumukit::Service
10
11
  json.as_json(options)
11
12
  end
12
13
 
13
- def [](key)
14
- json[key]
15
- end
16
-
17
14
  def method_missing(name, *args)
18
- json[name]
15
+ if args.size == 0
16
+ self[name]
17
+ elsif args.size == 1
18
+ self[name[0..-2]] = args.first
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ def []=(key, value)
25
+ @raw[key.to_sym] = value
26
+ @json = nil
19
27
  end
20
28
 
21
29
  def transforms(original)
@@ -1,6 +1,7 @@
1
1
  module Mumukit::Service
2
2
  class DocumentArray
3
3
  attr_accessor :raw
4
+ delegate :each, to: :raw
4
5
 
5
6
  def initialize(raw, options={})
6
7
  @raw = raw
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Service
3
- VERSION = '0.5.1'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-09 00:00:00.000000000 Z
11
+ date: 2016-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler