structure 1.2.0 → 1.2.1

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
  SHA256:
3
- metadata.gz: 6b08d68f313a052ecf51e5ddae25a9c01b2fa97f4d62faffd0886036f2143569
4
- data.tar.gz: '0330855f5dbce7826cbdc2c845e719c81e6b1e60e17fcf5bc3a58a496ffa2944'
3
+ metadata.gz: a6b0dd37534ddbab651d055ac20449409d4d2a26f943b5ece647eafe56d0be1a
4
+ data.tar.gz: 9b41302fd50f1d031a55f46fb656e1c2985f3a6ca39b48997992de2a9355ad44
5
5
  SHA512:
6
- metadata.gz: 0c4bfbe6e6cbeaaf3440b71894f469e03b71eb272a570bd127923960eddec434750badd66d5258a79ee559b4c59f5be9141ab9595eb7f82b27108f5e26340751
7
- data.tar.gz: 48fa29e4f97245598a2af38667e32b4bee11e87c65944c9570219fb764e0383a3d4bdaf5b71d403cde00f0e4dcff7bdb68f25566d2cb8f866b1f9c8ee1ae2913
6
+ metadata.gz: 1a85161835d1cc3e87ae05dcb5d2ada4647a360a4df5260f6adc5679db9e1d1b397924e6c6e2933aed87a27dc154d5049178abbbb8e0de1393b6965fa8b8ed02
7
+ data.tar.gz: 20e3a9416b98321020959cc8f3522d6c07843a78df69428a87291d1f60eb1d2aab2ac9d8bf51ecd0878b1ba69d1aea72465f6cec0126644b3779633a10d2b5d3
data/lib/structure.rb CHANGED
@@ -61,4 +61,10 @@ module Structure
61
61
  alias to_h attributes
62
62
  alias eql? ==
63
63
  alias to_s inspect
64
+
65
+ private
66
+
67
+ def __exclusive(&block)
68
+ @__mutex.owned? ? block.call : @__mutex.synchronize { block.call }
69
+ end
64
70
  end
@@ -24,21 +24,18 @@ module Structure
24
24
 
25
25
  module_eval <<-CODE, __FILE__, __LINE__ + 1
26
26
  def #{name}
27
- @__mutex.synchronize {
27
+ __exclusive {
28
28
  break if @__table.key?("#{name}")
29
29
 
30
- @__table["#{name}"] = __#{name}
30
+ @__table["#{name}"] = __get_#{name}
31
31
  @__table["#{name}"].freeze
32
-
33
- @__table["#{name}"]
34
32
  }
35
33
 
36
34
  @__table["#{name}"]
37
35
  end
38
36
  CODE
39
37
 
40
- define_method "__#{name}", block
41
- private "__#{name}"
38
+ private define_method "__get_#{name}", block
42
39
 
43
40
  @attribute_names << name
44
41
 
@@ -24,7 +24,7 @@ module Structure
24
24
 
25
25
  attribute_names.each do |name|
26
26
  module_eval <<-CODE, __FILE__, __LINE__ + 1
27
- private def __#{name}
27
+ private def __get_#{name}
28
28
  @#{name}
29
29
  end
30
30
  CODE
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Structure
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari