evt-attribute 0.1.3.5 → 0.2.0.0

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
- SHA1:
3
- metadata.gz: 7134ce04e4e94f5696a4bd78030766923b70ef69
4
- data.tar.gz: b8a1057a2bbc4300c04d128f46561df69b83a1c4
2
+ SHA256:
3
+ metadata.gz: f0df53a6f66244e4532255bc353b24ad56bd5733facc2dbca715ff23859ae054
4
+ data.tar.gz: 687e78fd78bbc5e762b4c27dadca6730691acc232e32d57d1e54ae7164639929
5
5
  SHA512:
6
- metadata.gz: 2fdca8a51f26acc904c6b3ca2c93b23eda79e38044cf33f3e8d62971e8e3b1925bb72cc34e2a3c7af89d9e2354d526266382e73f7df7b01bceb1d5d6f897a701
7
- data.tar.gz: 404246c0caba7b0f8b5bdbd271c149d409a81e9f77c698d6b4c4c50c93d4d9adde7e5567f29d9be9e48ac7c4ff0cda3485d14b9f3d82fcd9552d6322c0b263fe
6
+ metadata.gz: ec57b9010672bf6540cc3bcdd9b61282a476a9ad3008f665c48775d63cefb42db95e7d0a9300a4f22a032170397cbf422683cf39ebefb7acdc100822f30043e8
7
+ data.tar.gz: 87217d5cd3d49eb9735900a4fab94f8faa0bcbb95b637b9dd210b7e173cf4a466ad6041b1b26caf54ef16dbafc285dcedd2df36332ada924d17f6fdd3ffe685e
@@ -0,0 +1,4 @@
1
+ require 'attribute/controls/reader'
2
+ require 'attribute/controls/writer'
3
+ require 'attribute/controls/accessor'
4
+ require 'attribute/controls/checked'
@@ -0,0 +1,25 @@
1
+ module Attribute
2
+ module Controls
3
+ module Accessor
4
+ def self.example
5
+ Example.new
6
+ end
7
+
8
+ class Example
9
+ Attribute::Define.(self, :some_attr, :accessor)
10
+ end
11
+
12
+ module InitialValue
13
+ def self.example
14
+ Example.new
15
+ end
16
+
17
+ class Example
18
+ Attribute::Define.(self, :some_attr, :accessor) do
19
+ :some_initial_value
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ module Attribute
2
+ module Controls
3
+ module Checked
4
+ Error = Class.new(RuntimeError)
5
+
6
+ def self.example
7
+ example = Example.new
8
+ example.some_attr = value
9
+ example
10
+ end
11
+
12
+ def self.value
13
+ 'some value'
14
+ end
15
+
16
+ class Example
17
+ Attribute::Define.(self, :some_attr, :accessor, check: -> (val) { raise Error unless val == Checked.value })
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ module Attribute
2
+ module Controls
3
+ module Reader
4
+ def self.example
5
+ Example.new
6
+ end
7
+
8
+ class Example
9
+ Attribute::Define.(self, :some_attr, :reader)
10
+ end
11
+
12
+ module Default
13
+ def self.example
14
+ Example.new
15
+ end
16
+
17
+ class Example
18
+ Attribute::Define.(self, :some_attr)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ module Attribute
2
+ module Controls
3
+ module Writer
4
+ def self.example
5
+ Example.new
6
+ end
7
+
8
+ class Example
9
+ Attribute::Define.(self, :some_attr, :writer)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -15,19 +15,22 @@ module Attribute
15
15
 
16
16
  attr_name
17
17
  end
18
- class << self; alias :! :call; end # TODO: Remove deprecated actuator [Kelsey, Thu Oct 08 2015]
19
18
 
20
19
  def define_reader(target_class, attr_name, visibility, check, &initialize_value)
21
20
  attr_name = :"#{attr_name}" unless attr_name.is_a? Symbol
22
21
  var_name = "@#{attr_name}"
23
22
  target_class.send :define_method, attr_name do
24
- val = instance_variable_get(var_name)
25
23
 
26
- if val.nil?
27
- if initialize_value
24
+ defined = instance_variable_defined?(var_name)
25
+
26
+ val = nil
27
+ if defined
28
+ val = instance_variable_get(var_name)
29
+ else
30
+ unless initialize_value.nil?
28
31
  val = initialize_value.()
29
- instance_variable_set var_name, val
30
32
  end
33
+ instance_variable_set var_name, val
31
34
  end
32
35
 
33
36
  if check
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.5
4
+ version: 0.2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-01 00:00:00.000000000 Z
11
+ date: 2018-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test_bench
@@ -31,6 +31,11 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/attribute.rb
34
+ - lib/attribute/controls.rb
35
+ - lib/attribute/controls/accessor.rb
36
+ - lib/attribute/controls/checked.rb
37
+ - lib/attribute/controls/reader.rb
38
+ - lib/attribute/controls/writer.rb
34
39
  - lib/attribute/define.rb
35
40
  homepage: https://github.com/eventide-project/attribute
36
41
  licenses:
@@ -52,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
57
  version: '0'
53
58
  requirements: []
54
59
  rubyforge_project:
55
- rubygems_version: 2.6.11
60
+ rubygems_version: 2.7.3
56
61
  signing_key:
57
62
  specification_version: 4
58
63
  summary: Define an attribute on a class using an imperative API