valued 0.3.0 → 0.4.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: 52725a53667c02e8762fbf0494b52f7641fc5d8228eddc83ceb8e8b6899b4ed7
4
- data.tar.gz: f997ebbf9cf7c114cf2db237f3b8042d585d50ae210426ee8c7f78cc42f204c8
3
+ metadata.gz: c09b1d932113939667c5e36981e3256b25483679ebc222131d377985152a70a9
4
+ data.tar.gz: 823e69bdf5587363b1cae66ce2bd68ed8f38aedcdca3bddac5e59b953c27414f
5
5
  SHA512:
6
- metadata.gz: 0d31a8cd00da586bd1b1708fffe04b6319a0892127da935f91bbba38043356611ac482ad25eb921a595a6d7ebedbf841a1cb10f4784762ebc77aa2d1ac79d797
7
- data.tar.gz: dc370f42d41c9d7df0a655d0ab591aabeac612221d98162bbf491eb68a582a217f4d634aea2111e95448c573768b15cc5a6c322f419ed31de57305feba524dec
6
+ metadata.gz: 7c050eb350406595297da5f44fddd9f8b87e7675ad72596eaf89b8de9075e4da48f873da3750d01f7bd47f986c56efe5dd295900a17f94c1d81aee22459d482f
7
+ data.tar.gz: bd235452be8f966895982d83b31650bd468af5922e27d97680f04f95e8557cfd87f5c82ca982dc36880b0f2b2b767d9c56fb573ec6e42ed6396c16f433e183e1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- valued (0.3.0)
4
+ valued (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -3,29 +3,13 @@ require 'valued/version'
3
3
 
4
4
  module Valued
5
5
  module ClassMethods
6
- def self.normalized_attributes(attributes)
7
- attributes.each_with_object(attributes) do |attr, result|
8
- result << attr.to_s.chomp('?').to_sym if attr.to_s.end_with?('?')
9
- end
10
- end
11
-
12
6
  def self.define_method(attr, klass)
13
- klass.class_eval do
14
- if attr.to_s.end_with?('?')
15
- define_method(attr) do
16
- instance_variable_get("@#{attr.to_s.chomp('?')}")
17
- end
18
- else
19
- attr_reader attr
20
- end
21
- end
7
+ klass.class_eval { attr_reader attr }
22
8
  end
23
9
 
24
10
  def attributes(*attributes)
25
11
  attributes.each { |attr| Valued::ClassMethods.define_method(attr, self) }
26
- define_method('_attributes') do
27
- Valued::ClassMethods.normalized_attributes(attributes)
28
- end
12
+ define_method('_attributes') { attributes }
29
13
  private :_attributes
30
14
  end
31
15
  end
@@ -49,7 +33,7 @@ module Valued
49
33
  _attributes.each do |attribute|
50
34
  if attributes.key?(attribute)
51
35
  instance_variable_set(
52
- "@#{attribute.to_s.chomp('?')}",
36
+ "@#{attribute}",
53
37
  attributes.fetch(attribute).freeze
54
38
  )
55
39
  end
@@ -1,32 +1,15 @@
1
1
  module Valued
2
2
  module Mutable
3
3
  module ClassMethods
4
- def self.normalized_attributes(attributes)
5
- attributes.each_with_object(attributes) do |attr, result|
6
- result << attr.to_s.chomp('?').to_sym if attr.to_s.end_with?('?')
7
- end
8
- end
9
-
10
4
  def self.define_method(attr, klass)
11
- klass.class_eval do
12
- if attr.to_s.end_with?('?')
13
- define_method(attr) do
14
- instance_variable_get("@#{attr.to_s.chomp('?')}")
15
- end
16
- attr_writer "#{attr.to_s.chomp('?')}".to_sym
17
- else
18
- attr_accessor attr
19
- end
20
- end
5
+ klass.class_eval { attr_accessor attr }
21
6
  end
22
7
 
23
8
  def attributes(*attributes)
24
9
  attributes.each do |attr|
25
10
  Valued::Mutable::ClassMethods.define_method(attr, self)
26
11
  end
27
- define_method('_attributes') do
28
- Valued::Mutable::ClassMethods.normalized_attributes(attributes)
29
- end
12
+ define_method('_attributes') { attributes }
30
13
  private :_attributes
31
14
  end
32
15
  end
@@ -49,10 +32,7 @@ module Valued
49
32
  def initialize(attributes = {})
50
33
  _attributes.each do |attribute|
51
34
  if attributes.key?(attribute)
52
- instance_variable_set(
53
- "@#{attribute.to_s.chomp('?')}",
54
- attributes.fetch(attribute)
55
- )
35
+ instance_variable_set("@#{attribute}", attributes.fetch(attribute))
56
36
  end
57
37
  end
58
38
  end
@@ -1,3 +1,3 @@
1
1
  module Valued
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valued
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Mainz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.38'
83
- description:
83
+ description:
84
84
  email:
85
85
  - mainz.mario@googlemail.com
86
86
  executables: []
@@ -107,7 +107,7 @@ licenses:
107
107
  metadata:
108
108
  homepage_uri: https://github.com/mmainz/valued
109
109
  source_code_uri: https://github.com/mmainz/valued
110
- post_install_message:
110
+ post_install_message:
111
111
  rdoc_options: []
112
112
  require_paths:
113
113
  - lib
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubygems_version: 3.1.2
126
- signing_key:
126
+ signing_key:
127
127
  specification_version: 4
128
128
  summary: A Ruby gem that makes it easy to create value objects.
129
129
  test_files: []