chainable_accessor 0.1.0 → 0.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: bbca9233e0b2925dfec9a64647724460eebf9871b0dbba8eee5a25a02afd6ab4
4
- data.tar.gz: f5cdf3345c3cd74aaa04df52c41b57ebc8534897118fd6db658ba95dc8019d10
3
+ metadata.gz: 181322f251c320410b5cffd05ec67554c69861c2e951bb087ff17ef29b2ac532
4
+ data.tar.gz: e5592e81b480fff56186bf14cbe2bb283dbb23860649d87e60d478efee4f923e
5
5
  SHA512:
6
- metadata.gz: 22f3be1b2fc4f6c2e6aa36f48256d22972bbd3b62a1df0cc579e4624bb1d07c3f412a883a33ee03cc586846982477369e15e410ddc539f4ec769d50375777fce
7
- data.tar.gz: eb1731e75558360d5eb5c642cf3b82ea4357e9c3ee74b99209880ca72a60c9eb8fef1eb2f3121341c3c1c3c9f4a885b7a70815490691eb5d74cc9db1606b66d3
6
+ metadata.gz: c6edc28de6d603cefc0079ebabbeac9afd78df539e73334639c1af485ad859ca94aed796bd775574e4c3920907e47e6932dd2fd2a036f42fec83b20802c485ff
7
+ data.tar.gz: 555355c7cf960055d3611bc1a7501325b9e10f773c99c6d8b72480bf146e32c99db1667012a91d09c6928c2660fedd0e8dec745d7c4c0b7a3029cae4a6c7ab2e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2021-08-12
4
+
5
+ - [Added] Support immutable
6
+
3
7
  ## [0.1.0] - 2021-08-12
4
8
 
5
9
  - Initial release
data/README.md CHANGED
@@ -23,8 +23,9 @@ Or install it yourself as:
23
23
 
24
24
  ```ruby
25
25
  class Search
26
- attr_accessor :word, :page, :sort
26
+ attr_accessor :word, :page, :sort, :foo, :bar
27
27
  chainable_accessor :word, :page, :sort
28
+ chainable_accessor :foo, :bar, immutable: true
28
29
  end
29
30
 
30
31
  Search.new.word('foo').page(1).sort(:released_at)
@@ -3,13 +3,13 @@
3
3
  require_relative 'chainable_accessor/version'
4
4
 
5
5
  module ChainableAccessor
6
- def chainable_accessor(*attributes)
6
+ def chainable_accessor(*attributes, immutable: false)
7
7
  mod = Module.new do
8
8
  attributes.each do |name|
9
9
  define_method name do |val = nil|
10
10
  return super() unless val
11
11
 
12
- tap { |x| x.send("#{name}=", val) }
12
+ (immutable ? dup : self).tap { |x| x.send("#{name}=", val) }
13
13
  end
14
14
  end
15
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChainableAccessor
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chainable_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - masarakki