prezzo 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/prezzo/explainable.rb +11 -3
- data/lib/prezzo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e68e4778b29b3cf78670d0096790d55914beb14f
|
4
|
+
data.tar.gz: 3d0694e12d2e317356e7eae95483eb07fea11003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a20557bd58a6a26268c159986e775220f8864a601e97186fe10f9ac4b9e89672d22d27dfb3c9525a1db96740bedf5834edb62c21afc1149e1120dc6edc05cbe
|
7
|
+
data.tar.gz: e32f05204cfc04690f6d1e657438fbc6e516ae4f9db5511a70c6e4b2c09338d720485d7b4e339cb0090cdb53d87af782e8e9464d60fdc5cf7c47fb14b94315e0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -150,7 +150,7 @@ end
|
|
150
150
|
|
151
151
|
context = Uber::Context.new(distance: 10.0)
|
152
152
|
Uber::RidePriceCalculator.new(context).explain
|
153
|
-
#=> { base_fare: 4.3, price_per_distance: 21.3 }
|
153
|
+
#=> { total: 25.6, components: { base_fare: 4.3, price_per_distance: 21.3 } }
|
154
154
|
```
|
155
155
|
|
156
156
|
Check the full [Uber pricing](/spec/integration/uber_pricing_spec.rb) for more complete example with many calculators and factors.
|
data/lib/prezzo/explainable.rb
CHANGED
@@ -7,11 +7,19 @@ module Prezzo
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module ClassMethods
|
10
|
-
def explain_with(*
|
10
|
+
def explain_with(*methods)
|
11
11
|
define_method(:explain) do
|
12
|
-
|
13
|
-
|
12
|
+
explanation = {
|
13
|
+
total: calculate,
|
14
|
+
}
|
15
|
+
|
16
|
+
components = methods.each_with_object({}) do |method, acc|
|
17
|
+
acc[method] = send(method)
|
14
18
|
end
|
19
|
+
|
20
|
+
explanation[:components] = components unless components.empty?
|
21
|
+
|
22
|
+
explanation
|
15
23
|
end
|
16
24
|
end
|
17
25
|
end
|
data/lib/prezzo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prezzo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Boeira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-validations
|