store_model 1.1.0 → 1.2.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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df54ca03d99d1173d2e94d32c6a8cc4fa4a503c8f6d7a26b77ff4275e9cf7420
4
- data.tar.gz: 011b0d5f4fe3532998bca81043895f0882a5f709245c4d688a0226ba17eb2cbb
3
+ metadata.gz: 6139e784c55ab957dc9de25a43b4727c91333dde4b7c92f4f22ea2634c204bf5
4
+ data.tar.gz: 04ae362612c4032445da8b05320e0d95f29a4b825bba751fa72811aabae263bd
5
5
  SHA512:
6
- metadata.gz: c4dad930177bc577c03a7f12959f57ac897dd1caa17c2817786e15e4e120dee2b1563778575c5eebcbaf9639abca7b8a8ea7bf9ba4f6ee93e2624267d4a06798
7
- data.tar.gz: dc0a1200e73a465832e3abb9b6778991395a8c70b19b0e1480b19f15b723d64bc7e259fdbeaef6be837c286767675bf44f1828173a8004edfa0f058f7db1888f
6
+ metadata.gz: fc7e96d96c1d4e8b7074b7d4000755137b3199b55769ff5e57ad59235e79cde8441e80d59133a54981788a94202df8b698484a896d4ea2d22dd90fdb3633736f
7
+ data.tar.gz: '001499ba6ff97ee59dc16fca855fbd9128fe9f6f85d4fe37438f4ea13bdea5ae81bf6da9281b8436b816573be6c79a15f68c6fdb0c3b610e7d23a897ba762b6b'
@@ -23,6 +23,8 @@ module StoreModel
23
23
 
24
24
  attr_accessor :parent
25
25
 
26
+ delegate :each_value, :fetch, to: :attributes
27
+
26
28
  # Returns a hash representing the model. Some configuration can be
27
29
  # passed through +options+.
28
30
  #
@@ -53,6 +55,23 @@ module StoreModel
53
55
  end
54
56
  alias eql? ==
55
57
 
58
+ # Accessing attribute using brackets
59
+ #
60
+ # @return [Object]
61
+ def [](attr_name)
62
+ @attributes.fetch_value(attr_name.to_s)
63
+ end
64
+
65
+ # Setting attribute using brackets
66
+ #
67
+ # @param name [String, Symbol]
68
+ # @param value [Object]
69
+ #
70
+ # @return [Object]
71
+ def []=(attr_name, value)
72
+ @attributes.write_from_user(attr_name.to_s, value)
73
+ end
74
+
56
75
  # Returns hash for a StoreModel::Model instance based on attributes hash
57
76
  #
58
77
  # @return [Integer]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoreModel # :nodoc:
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-31 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -120,7 +120,7 @@ homepage: https://github.com/DmitryTsepelev/store_model
120
120
  licenses:
121
121
  - MIT
122
122
  metadata: {}
123
- post_install_message:
123
+ post_install_message:
124
124
  rdoc_options: []
125
125
  require_paths:
126
126
  - lib
@@ -135,8 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.3.3
139
- signing_key:
138
+ rubygems_version: 3.1.6
139
+ signing_key:
140
140
  specification_version: 4
141
141
  summary: Gem for working with JSON-backed attributes as ActiveRecord models
142
142
  test_files: []