attr_extras 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzZmMWUzNjNiYWMzODYzYzZjODI1YzQwNDljYzliMGE4ZjFkY2IwMw==
4
+ ZDczYjI3ZTEyMzdmMWM3NjMwYmIzZGFhODRjMDJmNTAxOGY4NmRhNg==
5
5
  data.tar.gz: !binary |-
6
- ZmZhZTI5NDYxMGUyMWRhYjIyYjMzYmFlOGNiYzdhN2EyN2NlZmViZQ==
6
+ MDY2ZjIwMWM4MzVjZWYwYWE2ZGFhZGYxMDRmMWU3MzBlMTFiOTFkOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjhlNTdiMWM1ODJkMWEyNDMyMTNlYjVlMWU2N2U5MjU1ODZiNmViNjg4MDQ4
10
- OWFhYTcyYzQ5ZGY1ZWM3OTczYjk3NjM4NDdjZjU2YjU2MjM4MjAzY2I3Mjc2
11
- MzcyNWZkZGE5NTE0NDExN2ZlNjc3YTZkYWFmOWZhY2RlMzVhNmQ=
9
+ NTNkOTlhMWJhODA4M2IxMjlkNjgxNDc0MTBiN2I2NDdhZWE0YmE2M2NkODQw
10
+ NTk3MjA5MGRjNDg5NjllNWYwNGZlNTUzZTYyYmQ0MGI3ZGI0MTFhOWY1Nzg1
11
+ OTUxMzlhODkxOGRjNDQwOTM0YzlkZWJiZWNiZTEyODg0ZDdhMjk=
12
12
  data.tar.gz: !binary |-
13
- NzY4NTk0Y2RkYzAwYzhkMzQ3Njc2NGI3NzYxNGNkYThkOTRjZjU3ODIzNDk2
14
- ZTA2NDQ1MGMxZmRjNjNhM2FjNThlNzI4MmE0MjA2ZjQ5YzM0Y2Y2YWQ3NDli
15
- ZDM1YTU0OGZmZGRkZmZhZjVhNTgzYjM0ZDE0ODM5OGI4ZTRiODk=
13
+ ODc1ODQ2YmQwNzdkNWVlZWZmZTA3NDllNGIyZDFlNmQyYjNkNWRiODEyMTI3
14
+ NmQ3N2Y0NTc3ZDMxOWM2YzAyMmYxZDJkZmFlM2MxZjA4MTUxODk2ZTQ3ODcx
15
+ YzcwNWEwZGM2N2Q4NDU5ZjI1YWM4NTk5YWIxMmIzY2Y0MGY1ZDM=
data/README.md CHANGED
@@ -93,15 +93,27 @@ class PriceCalculator
93
93
  :order
94
94
 
95
95
  def calculate
96
- order.price * factor
96
+ total * factor
97
97
  end
98
98
 
99
99
  private
100
100
 
101
+ def total
102
+ order.items.map(&:price).inject(:+)
103
+ end
104
+
101
105
  def factor
102
106
  1 + rand
103
107
  end
104
108
  end
109
+
110
+ class Order
111
+ def price
112
+ PriceCalculator.calculate(self)
113
+ end
114
+
115
+ # …
116
+ end
105
117
  ```
106
118
 
107
119
  Shortcut for
data/attr_extras.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  require File.expand_path('../lib/attr_extras/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Henrik Nyh", "Joakim Kolsjö"]
5
+ gem.authors = ["Henrik Nyh", "Joakim Kolsjö", "Victor Arias"]
6
6
  gem.email = ["henrik@nyh.se"]
7
7
  gem.summary = %q{Takes some boilerplate out of Ruby with methods like attr_initialize.}
8
8
  gem.homepage = "https://github.com/barsoom/attr_extras"
@@ -3,7 +3,7 @@ module AttrExtras::AttrQuery
3
3
  names.each do |name|
4
4
  name = name.to_s
5
5
 
6
- raise "#{__method__} wants `#{name}?`, not `#{name}`." unless name.end_with?("?")
6
+ raise ArgumentError, "#{__method__} wants `#{name}?`, not `#{name}`." unless name.end_with?("?")
7
7
 
8
8
  klass.send(:define_method, name) do # def foo?
9
9
  !!send("#{name.chop}#{suffix}") # !!send("foo_id")
@@ -1,3 +1,3 @@
1
1
  module AttrExtras
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -230,7 +230,7 @@ describe Object, ".attr_id_query" do
230
230
  end
231
231
 
232
232
  it "requires a trailing questionmark" do
233
- lambda { Object.attr_id_query(:foo) }.must_raise RuntimeError
233
+ lambda { Object.attr_id_query(:foo) }.must_raise ArgumentError
234
234
  end
235
235
  end
236
236
 
@@ -248,7 +248,7 @@ describe Object, ".attr_query" do
248
248
  end
249
249
 
250
250
  it "requires a trailing questionmark" do
251
- lambda { Object.attr_query(:foo) }.must_raise RuntimeError
251
+ lambda { Object.attr_query(:foo) }.must_raise ArgumentError
252
252
  end
253
253
  end
254
254
 
metadata CHANGED
@@ -1,11 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  - Joakim Kolsjö
9
+ - Victor Arias
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []