lean-attributes 0.2.0 → 0.3.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjNkZDIxZDUzMGFkMWE5MGNiM2U3NGVhMTkzOWVmNDFkNWJmNTMwZg==
4
+ YmE0YWM3ZjBjMDJhYzBkMzNmMmIxMjgyM2FjM2U2ZDhjYmVkMTIxZg==
5
5
  data.tar.gz: !binary |-
6
- NmUwMTkxOGE4MDkyZjFiNmUwODFmNzQ4Y2U4OTlmNTlkYWUxN2Q4NA==
6
+ YWIyODY5MTE5MTYxNzJkMDA0NDY1M2Q1ZTIwODU0Y2JkZDkwZGZmYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDUyMGU1OTY2NmUyYzY2YTNjMmE5MmE4MDk1YmQ1MTBiOTc0MGZjNzM4MzJl
10
- NWY1ZmRhOGZjYzdjZGU5MGYzOGM4NDk2Y2I5YTkxNjhiMjVhYTg3NDYzY2Ux
11
- YjI2ZjY5YjRmMWY5YjQ5NTFiMDBlYzljMjY2Y2I4ZTFiNzgzYWM=
9
+ N2Q0ODkzNGVlNmZmZjMzMmM2OWY4YzM3MWQzYTRlMTg0ZGEyNGJiMTMwYmJh
10
+ ZjU3MDdmZjBhZjkyZDg0NzUwMDUyODU3YjNiNjI5MWU4NmYxYmI0M2FjMDNh
11
+ Yzg3MTJmNDhjMGM1Y2JiODBmNmFhZDkxOWE2YWFiMWZjODZiMWY=
12
12
  data.tar.gz: !binary |-
13
- MDQ3YzZhZTBiMThmYTMxMzdhMjg1MWQ1ZmY4MWM2Nzc2MWE4OGRjYTQzNGVl
14
- Y2FiODYwZGQwMmNhNDRkNzU3ZWEyYjg5NThkMjQ3MTJjZTQ1YWUxY2RkMDlh
15
- NTBiNmIzZGY5ZTg5ODMwOGQzZDQwNTQxMzk1ZGI4NDJiYTExMDE=
13
+ MWM5ZGIzYjM3MzU1OWNlYWNkYjg2ZmRhZDk4MjE3MTM3M2M0MzFiNTNkMmE1
14
+ YWQ3MDkxMTllNTNkNTM2ZDdiZGVhYWY3MGZmMzEwMTZlMjhhNDVhMzdhOWFk
15
+ MDI2YTAxNjU1ZThkN2Y1ZTg0MzBmNTViYmQxZTU2ZjBiOTc3YWQ=
@@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## [Unreleased][unreleased]
6
6
 
7
+ ## [0.3.0] - 2016-03-07
8
+ ### Added
9
+ - Adds benchmarks for ActiveAttr
10
+ - Adds benchmarks for ActiveRecord::Attributes
11
+ - Adds basic support for boolean attributes
12
+
7
13
  ## [0.2.0] - 2015-09-18
8
14
  ### Added
9
15
  - Adds content to README.md
@@ -31,6 +37,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
31
37
  ### Added
32
38
  - Initial release
33
39
 
34
- [unreleased]: https://github.com/lleolin/lean-attributes/compare/v0.1.0...HEAD
40
+ [unreleased]: https://github.com/lleolin/lean-attributes/compare/v0.3.0...HEAD
41
+ [0.3.0]: https://github.com/lleolin/lean-attributes/compare/v0.2.0...v0.3.0
42
+ [0.2.0]: https://github.com/lleolin/lean-attributes/compare/v0.1.0...v0.2.0
35
43
  [0.1.0]: https://github.com/lleolin/lean-attributes/compare/v0.0.2...v0.1.0
36
44
  [0.0.2]: https://github.com/lleolin/lean-attributes/compare/v0.0.1...v0.0.2
data/README.md CHANGED
@@ -92,6 +92,9 @@ class ReadingProgress
92
92
  value
93
93
  end
94
94
  end
95
+
96
+ # progress = ReadingProgress.new(current_page: 0)
97
+ # progress.current_page # => 1
95
98
  ```
96
99
 
97
100
  Another way to contain such behavior is to create a `CurrentPage` class to represent your attribute instead of an Integer. The power is yours.
@@ -100,18 +103,24 @@ Another way to contain such behavior is to create a `CurrentPage` class to repre
100
103
  Lean::Attributes is meant to be relatively lightweight and fast.
101
104
 
102
105
  ```
103
- FastAttributes: without values : 3499535.3 i/s
104
- Lean::Attributes: without values : 3467944.9 i/s - 1.01x slower
105
- Lean::Attributes: integer values for integer attributes : 151398.8 i/s - 23.11x slower
106
- FastAttributes: integer values for integer attributes : 140099.8 i/s - 24.98x slower
107
- Lean::Attributes: string values for integer attributes : 139070.9 i/s - 25.16x slower
108
- FastAttributes: string values for integer attributes : 124387.2 i/s - 28.13x slower
109
- Virtus: integer values for integer attributes : 36776.0 i/s - 95.16x slower
110
- Attrio: integer values for integer attributes : 19452.5 i/s - 179.90x slower
111
- Virtus: without values : 18184.8 i/s - 192.44x slower
112
- Attrio: string values for integer attributes : 17689.9 i/s - 197.83x slower
113
- Attrio: without values : 12769.1 i/s - 274.06x slower
114
- Virtus: string values for integer attributes : 5043.4 i/s - 693.88x slower
106
+ Lean::Attributes: without values : 3119783.8 i/s
107
+ FastAttributes: without values : 3055309.1 i/s - 1.02x slower
108
+ ActiveAttr: without values : 1554020.1 i/s - 2.01x slower
109
+ Lean::Attributes: integer values for integer attributes : 153202.6 i/s - 20.36x slower
110
+ Lean::Attributes: string values for integer attributes : 141380.5 i/s - 22.07x slower
111
+ FastAttributes: integer values for integer attributes : 121248.2 i/s - 25.73x slower
112
+ FastAttributes: string values for integer attributes : 116990.4 i/s - 26.67x slower
113
+ Virtus: integer values for integer attributes : 35510.1 i/s - 87.86x slower
114
+ ActiveRecord: without values : 33943.3 i/s - 91.91x slower
115
+ ActiveAttr: integer values for integer attributes : 23016.1 i/s - 135.55x slower
116
+ ActiveAttr: string values for integer attributes : 22838.5 i/s - 136.60x slower
117
+ Virtus: without values : 17894.9 i/s - 174.34x slower
118
+ Attrio: integer values for integer attributes : 16326.6 i/s - 191.09x slower
119
+ Attrio: string values for integer attributes : 15921.3 i/s - 195.95x slower
120
+ ActiveRecord: string values for integer attributes : 13286.4 i/s - 234.81x slower
121
+ ActiveRecord: integer values for integer attributes : 12595.4 i/s - 247.69x slower
122
+ Attrio: without values : 11723.0 i/s - 266.13x slower
123
+ Virtus: string values for integer attributes : 4925.7 i/s - 633.36x slower
115
124
  ```
116
125
 
117
126
  ## Versioning
@@ -157,8 +157,7 @@ module Lean
157
157
  #
158
158
  # # generated method:
159
159
  # # def pages=(value)
160
- # # value = coerce_pages(value)
161
- # # @pages = value
160
+ # # @pages = coerce_pages(value)
162
161
  # # end
163
162
  # end
164
163
  #
@@ -166,8 +165,7 @@ module Lean
166
165
  def setter_method
167
166
  <<-EOS
168
167
  def #{name}=(value)
169
- value = #{coercion_method_name}(value)
170
- @#{name} = value
168
+ @#{name} = #{coercion_method_name}(value)
171
169
  end
172
170
  EOS
173
171
  end
@@ -16,6 +16,7 @@ module Lean
16
16
  METHOD_BODIES = {
17
17
  Array: 'Array(value)',
18
18
  BigDecimal: 'BigDecimal.new(value, 0)',
19
+ Boolean: 'value ? true : false',
19
20
  Date: 'Date.parse(value)',
20
21
  DateTime: 'DateTime.parse(value)',
21
22
  Float: 'value.to_f',
@@ -23,7 +24,7 @@ module Lean
23
24
  String: 'value.to_s',
24
25
  Symbol: 'value.to_s.to_sym',
25
26
  Time: 'Time.parse(value).utc'
26
- }
27
+ }.freeze
27
28
 
28
29
  # Fetches or generates the method body for coercing a value to this type
29
30
  #
@@ -1,5 +1,5 @@
1
1
  module Lean
2
2
  module Attributes
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lean-attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - R. Elliott Mason
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake