c80_shared 0.1.30 → 0.1.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ea5ee1185bdae0322323c6ce97c444cd3e5b72f2553ebb2759a39833f698964
4
- data.tar.gz: bfc619cf91108d53e7b2adc0e4b3eccf6415b5f628d3ef9efd692a00c3e9c460
3
+ metadata.gz: 67ee8d9c2b4f04abc4ed5421e832edcdc9a03db966d6f43d70cea4305ced4ae6
4
+ data.tar.gz: b773639ed62b3d0c23c5c3ba0117c5b58ac32e12a9e86dac749205bf968549d6
5
5
  SHA512:
6
- metadata.gz: d3a51fcbd6d52a7b86070cd55a6b744d9877af0628cc1c0910c1d652e5d535648eb407451935ea91e2f751880d9027bc1d62fb3f78c50d499b5b16087f22e526
7
- data.tar.gz: 1f62ae502e89032fb59df3f40991082589fa5a0f74d5d1f7ea3c416f643624a103705b0583cca5d9337ce12bfafc79d2991fe2228ee00a51468ee5602e3aabcf
6
+ metadata.gz: 1fdd80cf449a1ccbd7ba17e346032f28d392bdbdfa0bcdb919b49902963c9481d2a34c6f5f54f99bc4f1a35d44963b8152e3b80eddbee6c61273bfd5cc0f5e22
7
+ data.tar.gz: 13b08b0e82d619f40aafac1ffd536ae183903ae0ce007218673301591a10c5eeaa17d2f042e27d5a5b39aac47baa2132e6c7c3711cb7a8a7318fe9043ced3086
@@ -57,7 +57,9 @@ class BoatSerializer < AbstractSerializer
57
57
  end
58
58
 
59
59
  def serialize(model, attributes: available_attributes, opts: {})
60
- super(model, attributes: attributes, opts: default_opts.merge(opts))
60
+ result = super(model, attributes: attributes, opts: default_opts.merge(opts))
61
+ result[:opts] = serialize_opts
62
+ result
61
63
  end
62
64
 
63
65
  def id(boat)
@@ -259,17 +261,21 @@ class BoatSerializer < AbstractSerializer
259
261
 
260
262
  def prices(boat)
261
263
  currency_id = ::Dicts::Currency.find_by_index(@opts[:currency]).id
262
- prices = if @opts[:business] == ::Dicts::Business::RENT.index
264
+ business = ::Dicts::Business.find_by_index @opts[:business]
265
+
266
+ prices = if business.index == ::Dicts::Business::RENT.index
263
267
  boat.boat_prices.select { |bp| bp.currency_id == currency_id }.map { |bp| ::BoatPriceSerializer.serialize bp }
264
268
  else
265
269
  # noinspection RubyResolve
266
270
  boat.boat_sale_prices.select { |bp| bp.currency_id == currency_id }.map { |bps| ::BoatSalePriceSerializer.serialize bps }
267
271
  end
268
-
269
272
  {
270
273
  prices: {
271
274
  list: prices,
272
- business: @opts[:business]
275
+ business: {
276
+ index: business.index,
277
+ id: business.id
278
+ }
273
279
  }
274
280
  }
275
281
  end
@@ -460,5 +466,32 @@ class BoatSerializer < AbstractSerializer
460
466
  def visits_total(boat)
461
467
  { visits_total: boat.visits_total }
462
468
  end
469
+
470
+ def serialize_opts
471
+ locale = ::Dicts::Locale.find_by_index @opts[:locale]
472
+ uol = ::Dicts::Length.find_by_index @opts[:uol]
473
+ business = ::Dicts::Business.find_by_index @opts[:business]
474
+ currency = ::Dicts::Currency.find_by_index @opts[:currency]
475
+
476
+ {
477
+ locale: {
478
+ index: locale.index,
479
+ id: locale.id
480
+ },
481
+ uol: {
482
+ index: uol.index,
483
+ id: uol.id
484
+ },
485
+ business: {
486
+ index: business.index,
487
+ id: business.id
488
+ },
489
+ currency: {
490
+ index: currency.index,
491
+ id: currency.id,
492
+ symbol: currency.symbol
493
+ }
494
+ }
495
+ end
463
496
  end
464
497
  end
@@ -1,3 +1,3 @@
1
1
  module C80Shared
2
- VERSION = "0.1.30"
2
+ VERSION = "0.1.31"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_shared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.30
4
+ version: 0.1.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-04 00:00:00.000000000 Z
11
+ date: 2019-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler