key-vortex 0.1.1 → 0.1.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1039a71bf775b3754d1ae275c5d70b39921cb4e390e39158ab4b6cde49fed5c8
4
- data.tar.gz: fa53fb6bd5aeca2c436b162e0c4bb37e7571de24eb279f334790bb239dc00c63
3
+ metadata.gz: f16908e843138ceefe28247b31cc1fe6b0a6e4c704174f7af7f98bcf8ac433dd
4
+ data.tar.gz: 759988a8108b14ca1be504c1a6eeb102b1efc86b970b33c6078fa4290963b67b
5
5
  SHA512:
6
- metadata.gz: 9b00849471bfd401f4db7ca3ce46ca5a1e47665b94c8d2f29eacba3ff55fb7174058629d82c61034c9eb6f820ee4f89be369e75249fd3f0f764d870a2071dbb2
7
- data.tar.gz: 2ff852525522a69fb833cea7acce7737687f9aa353c9f6c83a23d8abd62ec0dcf2bc1019a94d0a74f0f6f329d2cee3fc90be59636822646d74e5fac0de918110
6
+ metadata.gz: 233359a3b6e85fe314abed09916491de40596ca47ac927dc18587970059c2470ef7071d6346baf67893e14416d041147130e62d2f4698011b81813b951225025
7
+ data.tar.gz: e4fc5a84f2726d24cbf2362890eb7dcfd2da5a67ad32e8982b73961f8acb0b34a94ff982a0075aa7a119008ead364bfa57608616729875801ac1efa0df44e332
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- key-vortex (0.1.1)
4
+ key-vortex (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ class KeyVortex
4
+ class Adapter
5
+ class Memory < KeyVortex::Adapter
6
+ def initialize(items)
7
+ super()
8
+ @items = items
9
+ end
10
+
11
+ def save(record)
12
+ @items[record.id] = record
13
+ end
14
+
15
+ def find(id)
16
+ @items[id]
17
+ end
18
+
19
+ def remove(key)
20
+ @items.delete(key)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class KeyVortex
4
+ class Record
5
+ def self.constraints
6
+ @constraints ||= {}
7
+ end
8
+
9
+ def self.field(type, **constraints)
10
+ self.constraints[type] = constraints
11
+ end
12
+
13
+ field :id
14
+
15
+ def initialize(fields)
16
+ @fields = fields
17
+ end
18
+
19
+ def respond_to_missing?(method, *args)
20
+ args.empty? && self.class.field_constraints(method)
21
+ end
22
+
23
+ def method_missing(method, *_args)
24
+ @fields[method]
25
+ end
26
+
27
+ def self.field_constraints(field)
28
+ @fields[field]
29
+ end
30
+ end
31
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class KeyVortex
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/key_vortex.rb CHANGED
@@ -4,5 +4,17 @@ require_relative "key_vortex/version"
4
4
 
5
5
  class KeyVortex
6
6
  class Error < StandardError; end
7
- # Your code goes here...
7
+
8
+ def initialize(adapter, record_class)
9
+ @adapter = adapter
10
+ @record_class = record_class
11
+ end
12
+
13
+ def save(record)
14
+ @adapter.save(record)
15
+ end
16
+
17
+ def find(id)
18
+ @adapter.find(id)
19
+ end
8
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: key-vortex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lambda Null
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-07 00:00:00.000000000 Z
11
+ date: 2023-07-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Defines abstractions that can be built on top of for key/value storage
14
14
  on different technologies (file, s3, sql, redis, etc.)
@@ -32,8 +32,8 @@ files:
32
32
  - bin/setup
33
33
  - key-vortex.gemspec
34
34
  - lib/key_vortex.rb
35
- - lib/key_vortex/memory.rb
36
- - lib/key_vortex/record/string.rb
35
+ - lib/key_vortex/adapter/memory.rb
36
+ - lib/key_vortex/record.rb
37
37
  - lib/key_vortex/version.rb
38
38
  - sig/record/store.rbs
39
39
  homepage: https://github.com/Lambda-Null/key-vortex
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class KeyVortex
4
- class Memory
5
- def initialize(items)
6
- @items = items
7
- end
8
-
9
- def set(key, item)
10
- @items[key] = item
11
- end
12
-
13
- def get(key)
14
- @items[key]
15
- end
16
-
17
- def remove(key)
18
- @items.delete(key)
19
- end
20
- end
21
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class KeyVortex
4
- class Record
5
- class String
6
- def initialize(value)
7
- @value = value
8
- end
9
- end
10
- end
11
- end