nina 0.1.0 → 0.1.1

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: c948dd7e2dadd58475f4153f5dd7162912d41706e4fbec08118470d69f8783db
4
- data.tar.gz: 9ad7e8f6dd835220d21d2afe5120bfcea1cf5dcd13241f531f14d3fcb448edaf
3
+ metadata.gz: 59b40ebfbf0d151bfa494c0656ee33725b11e3ce6bb3934f20ee84d62cdec19c
4
+ data.tar.gz: a821c8aa025985bbfe3036e4a091cf29c4007939e32f3ba183379c0f9902bf59
5
5
  SHA512:
6
- metadata.gz: b24e8b48fa8744df3395b5f936cacd723c97285d5acc2b9f0e5d5edb5fac6e86caad86a8ef20968bd53210f37f663d56520c2a2becaeda38d92b95162aa2112b
7
- data.tar.gz: 64eac812b99e18afa87ce146d0eb2cf77ad08efba781303b397b70d6edb320fa66856879635af1d98ae6cd86d9970790e1b419b0d08c190e330336ea0f27cb24
6
+ metadata.gz: 2441cf19ef6c542fc567384f475f6c21956de6a89dd1dd100f3b993c92e463034527235a3a599088c759c7f32de3ece32d38822a4bb45afbb87087080d81a865
7
+ data.tar.gz: c5b7297094aab27bac3bae21f438360ee63b2314c875179c21bdede94ba7b0fece93633706d46e34c040a9346b5efb64577412ea7d90dec4a33e4777f46bbdc5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2023-07-05
4
+
5
+ ### Added
6
+ * Support for multiple callbacks
7
+
3
8
  ## [0.1.0] - 2023-05-18
4
9
 
5
10
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nina (0.1.0)
4
+ nina (0.1.1)
5
5
  toritori (= 0.1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Nina
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/nina.svg)](https://badge.fury.io/rb/nina)
3
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/435ee6e0ae846e9deb88/maintainability)](https://codeclimate.com/github/andriy-baran/nina/maintainability)
4
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/435ee6e0ae846e9deb88/test_coverage)](https://codeclimate.com/github/andriy-baran/nina/test_coverage)
5
6
 
@@ -83,6 +84,7 @@ instance = builder.nest(delegate: true)
83
84
  instance.a # => nil
84
85
  instance.b # => nil
85
86
  instance.c # => nil
87
+ instance.query.c # => nil
86
88
  ```
87
89
  If you need provide an initalization parameters for the objects
88
90
  ```ruby
@@ -94,18 +96,19 @@ end
94
96
  instance.a # => 1
95
97
  instance.b # => 2
96
98
  instance.c # => 3
97
- instance.query.c # => 3
98
99
  ```
99
100
  To do something between stages (after creation of object)
100
101
  ```ruby
101
- instance = builder.wrap(delegate: true) do |b|
102
- b.params { _1.a = 'a' }
103
- b.query { _1.b = 'b' }
104
- b.command { _1.c = 'c' }
102
+ builder_with_callbacks = builder.with_callbacks do |c|
103
+ c.params { _1.a = 1 }
104
+ c.params { _1.a += 3 }
105
+ c.params { _1.a += 2 }
106
+ c.query { _1.b = 2 }
105
107
  end
106
- instance.a # => 'a'
107
- instance.b # => 'b'
108
- instance.c # => 'c'
108
+ instance = builder_with_callbacks.wrap
109
+ instance.query.params.a # => 6
110
+ instance.query.b # => 2
111
+ instance.c # => nil
109
112
  ```
110
113
 
111
114
  ## Development
@@ -3,8 +3,6 @@
3
3
  module Nina
4
4
  # Generates module that adds support for objects creation
5
5
  class Assembler
6
- NOOP_PROC = proc {}
7
-
8
6
  # Adds ability to delegeate methods via method_missing
9
7
  module MethodMissingDelegation
10
8
  def method_missing(name, *attrs, &block)
@@ -34,7 +32,7 @@ module Nina
34
32
  build_order.each.with_index(-1).inject(nil) do |prev, (name, idx)|
35
33
  object = create_object(name, initialization)
36
34
  self.class.def_accessor(build_order[idx], on: object, to: prev, delegate: delegate) if prev
37
- callbacks.to_h.fetch(name, NOOP_PROC)[object] if callbacks
35
+ callbacks.to_h.fetch(name, []).each { |c| c.call(object) } if callbacks
38
36
  object
39
37
  end
40
38
  end
data/lib/nina/builder.rb CHANGED
@@ -38,7 +38,8 @@ module Nina
38
38
  return super unless @list.include?(method)
39
39
 
40
40
  @atts[method] unless block
41
- @atts[method] = block
41
+ @atts[method] ||= []
42
+ @atts[method] << block
42
43
  end
43
44
  end
44
45
 
data/lib/nina/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nina
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrii Baran
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-17 00:00:00.000000000 Z
11
+ date: 2023-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toritori