memory_record 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 42384e2c065906f318f6b46cf58200e3d2b72f28
4
- data.tar.gz: 1caef9514c4b62b8807f19fe87ccb7c97c7b8250
3
+ metadata.gz: 063507373c9804d614a625074869927806ab0e6b
4
+ data.tar.gz: 0e3d94306f86a3c3464ad2bc4766d55a1ca51f77
5
5
  SHA512:
6
- metadata.gz: 1834685035a93dbb9606798c0837ce07ec2a61ede9f6dfb6b7de16b5fc807efbb8e713ac3918d2b8b99fd08647e14eedd370caa010e3c4224d404e02fbdf0f65
7
- data.tar.gz: fdc248682afc325efbac0c660aa3ca2c5439f30dc6a61785cb6b4d2141c402b0ddb26ff02d4c1aca6338d5b6199d75bd5ee4b45a0020d96672a60ee0fc3e70a4
6
+ metadata.gz: cc74b9ccd21579395ecacc9b0072724739c27cc6351ad867580f46a22719d083862bf97e5d2e80176a66dc5edaa6cd75975ad0c6bf40bb49bc098fe1b97beae2
7
+ data.tar.gz: d6a45521aab7de0e692f23d229eb6462746dd87aae7c33e091fd33278ddd508763e2290a4e56b464a7e3148925226cc54f22b881f5ec60de836bb4400651a6f4
data/README.org CHANGED
@@ -129,6 +129,8 @@ Foo.fetch_if(:xxx) # => <KeyError: ...>
129
129
 
130
130
  *** How can I prohibit the hash key from being attr_reader automatically?
131
131
 
132
+ **** attr_reader: false
133
+
132
134
  I think that it is better to use it when you want to make it difficult to access easily.
133
135
 
134
136
  #+BEGIN_SRC ruby
@@ -136,12 +138,46 @@ class Foo
136
138
  include MemoryRecord
137
139
  memory_record attr_reader: false do
138
140
  [
139
- {x: 1},
141
+ {x: 1, y: 1, z: 1},
142
+ ]
143
+ end
144
+ end
145
+
146
+ Foo.first.x rescue $! # => #<NoMethodError: undefined method `x' for #<Foo:0x007fb2c710eda8>>
147
+ Foo.first.y rescue $! # => #<NoMethodError: undefined method `y' for #<Foo:0x007fb2c710eda8>>
148
+ Foo.first.z rescue $! # => #<NoMethodError: undefined method `z' for #<Foo:0x007fb2c710eda8>>
149
+ #+END_SRC
150
+
151
+ **** attr_reader: {only: :y}
152
+
153
+ #+BEGIN_SRC ruby
154
+ class Foo
155
+ include MemoryRecord
156
+ memory_record attr_reader: {only: :y} do
157
+ [
158
+ {x: 1, y: 1, z: 1},
159
+ ]
160
+ end
161
+ end
162
+
163
+ Foo.first.x rescue $! # => #<NoMethodError: undefined method `x' for #<Foo:0x007fcc861ff108>>
164
+ Foo.first.y rescue $! # => 1
165
+ Foo.first.z rescue $! # => #<NoMethodError: undefined method `z' for #<Foo:0x007fcc861ff108>>
166
+ #+END_SRC
167
+
168
+ **** attr_reader: {except: :x}
169
+
170
+ #+BEGIN_SRC ruby
171
+ class Foo
172
+ include MemoryRecord
173
+ memory_record attr_reader: {except: :y} do
174
+ [
175
+ {x: 1, y: 1, z: 1},
140
176
  ]
141
177
  end
142
178
  end
143
179
 
144
- Foo.first.x rescue $! # => #<NoMethodError: undefined method `x' for #<Foo:0x007fb070a5d4d0>>
145
- Foo.first[:x] # => 1
146
- Foo.first.attributes[:x] # => 1
180
+ Foo.first.x rescue $! # => 1
181
+ Foo.first.y rescue $! # => #<NoMethodError: undefined method `y' for #<Foo:0x007ff033895e88>>
182
+ Foo.first.z rescue $! # => 1
147
183
  #+END_SRC
@@ -10,32 +10,32 @@ class C1
10
10
  end
11
11
  end
12
12
 
13
- C1.first.x rescue $! # => #<NoMethodError: undefined method `x' for #<C1:0x007fb2c710eda8>>
14
- C1.first.y rescue $! # => #<NoMethodError: undefined method `y' for #<C1:0x007fb2c710eda8>>
15
- C1.first.z rescue $! # => #<NoMethodError: undefined method `z' for #<C1:0x007fb2c710eda8>>
13
+ C1.first.x rescue $! # => #<NoMethodError: undefined method `x' for #<C1:0x007ff0338d65c8>>
14
+ C1.first.y rescue $! # => #<NoMethodError: undefined method `y' for #<C1:0x007ff0338d65c8>>
15
+ C1.first.z rescue $! # => #<NoMethodError: undefined method `z' for #<C1:0x007ff0338d65c8>>
16
16
 
17
17
  class C2
18
18
  include MemoryRecord
19
- memory_record attr_reader: {only: :x} do
19
+ memory_record attr_reader: {only: :y} do
20
20
  [
21
21
  {x: 1, y: 1, z: 1},
22
22
  ]
23
23
  end
24
24
  end
25
25
 
26
- C2.first.x rescue $! # => 1
27
- C2.first.y rescue $! # => #<NoMethodError: undefined method `y' for #<C2:0x007fb2c70e6df8>>
28
- C2.first.z rescue $! # => #<NoMethodError: undefined method `z' for #<C2:0x007fb2c70e6df8>>
26
+ C2.first.x rescue $! # => #<NoMethodError: undefined method `x' for #<C2:0x007ff0338ae780>>
27
+ C2.first.y rescue $! # => 1
28
+ C2.first.z rescue $! # => #<NoMethodError: undefined method `z' for #<C2:0x007ff0338ae780>>
29
29
 
30
30
  class C3
31
31
  include MemoryRecord
32
- memory_record attr_reader: {except: :x} do
32
+ memory_record attr_reader: {except: :y} do
33
33
  [
34
34
  {x: 1, y: 1, z: 1},
35
35
  ]
36
36
  end
37
37
  end
38
38
 
39
- C3.first.x rescue $! # => #<NoMethodError: undefined method `x' for #<C3:0x007fb2c70ce668>>
40
- C3.first.y rescue $! # => 1
39
+ C3.first.x rescue $! # => 1
40
+ C3.first.y rescue $! # => #<NoMethodError: undefined method `y' for #<C3:0x007ff033895e88>>
41
41
  C3.first.z rescue $! # => 1
@@ -1,3 +1,3 @@
1
1
  module MemoryRecord
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memory_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - akicho8