Class: BoatSerializer
- Inherits:
-
AbstractSerializer
- Object
- AbstractSerializer
- BoatSerializer
- Defined in:
- app/serializers/boat_serializer.rb
Class Method Summary collapse
- .available_attributes ⇒ Object
- .boat_beam_metrics(boat) ⇒ Object
- .boat_beam_metrics_ft(boat) ⇒ Object
- .boat_beam_metrics_meters(boat) ⇒ Object
-
.boat_contacts(boat) ⇒ Object
Контакты владельцев: то, что приходит в
boat_users_attributesиз админской формы. - .boat_draft_metrics(boat) ⇒ Object
- .boat_draft_metrics_ft(boat) ⇒ Object
- .boat_draft_metrics_meters(boat) ⇒ Object
- .boat_hull_id(boat) ⇒ Object
- .boat_length_metrics(boat) ⇒ Object
- .boat_length_metrics_ft(boat) ⇒ Object
- .boat_length_metrics_meters(boat) ⇒ Object
- .boat_model(boat) ⇒ Object
- .boat_photos(boat) ⇒ Object
- .boat_type(boat) ⇒ Object
- .boat_type_id(boat) ⇒ Object
- .builder(boat) ⇒ Object
- .built_year(boat) ⇒ Object
-
.charter_1_day_high_discount(boat) ⇒ Object
–[discount]——————————————————————————————————.
- .charter_1_day_high_eur(boat) ⇒ Object
- .charter_1_day_high_rub(boat) ⇒ Object
- .charter_1_day_high_usd(boat) ⇒ Object
- .charter_1_day_low_discount(boat) ⇒ Object
- .charter_1_day_low_eur(boat) ⇒ Object
- .charter_1_day_low_rub(boat) ⇒ Object
- .charter_1_day_low_usd(boat) ⇒ Object
- .charter_1_hour_high_discount(boat) ⇒ Object
- .charter_1_hour_high_eur(boat) ⇒ Object
- .charter_1_hour_high_rub(boat) ⇒ Object
-
.charter_1_hour_high_usd(boat) ⇒ Object
–[high]———————————————————————————————————–.
- .charter_1_hour_low_discount(boat) ⇒ Object
- .charter_1_hour_low_eur(boat) ⇒ Object
- .charter_1_hour_low_rub(boat) ⇒ Object
-
.charter_1_hour_low_usd(boat) ⇒ Object
–[low]———————————————————————————————————–.
- .charter_1_month_high_discount(boat) ⇒ Object
- .charter_1_month_high_eur(boat) ⇒ Object
- .charter_1_month_high_rub(boat) ⇒ Object
- .charter_1_month_high_usd(boat) ⇒ Object
- .charter_1_month_low_discount(boat) ⇒ Object
- .charter_1_month_low_eur(boat) ⇒ Object
- .charter_1_month_low_rub(boat) ⇒ Object
- .charter_1_month_low_usd(boat) ⇒ Object
- .charter_1_week_high_discount(boat) ⇒ Object
- .charter_1_week_high_eur(boat) ⇒ Object
- .charter_1_week_high_rub(boat) ⇒ Object
- .charter_1_week_high_usd(boat) ⇒ Object
- .charter_1_week_low_discount(boat) ⇒ Object
- .charter_1_week_low_eur(boat) ⇒ Object
- .charter_1_week_low_rub(boat) ⇒ Object
- .charter_1_week_low_usd(boat) ⇒ Object
- .crew_total(boat) ⇒ Object
- .default_opts ⇒ Object
- .guest_cabins(boat) ⇒ Object
- .guests_total(boat) ⇒ Object
- .hull_material(boat) ⇒ Object
- .id(boat) ⇒ Object
- .interior_designer(boat) ⇒ Object
- .latitude(boat) ⇒ Object
- .location_address(boat) ⇒ Object
- .longitude(boat) ⇒ Object
- .main_boat_photo_id(boat) ⇒ Object
- .motor(boat) ⇒ Object
- .name(boat) ⇒ Object
-
.name_builder(boat) ⇒ Object
Для страницы просмотра лодки.
- .naval_architect(boat) ⇒ Object
-
.per_season(boat) ⇒ Object
per day, per week; в день, в час, за месяц;.
-
.picture_medium_url(boat) ⇒ Object
noinspection RubyResolve.
-
.price(boat) ⇒ Object
₽ 293,885.
-
.price_discount(boat) ⇒ Object
12%.
- .refit_year(boat) ⇒ Object
- .sale_price_discount(boat) ⇒ Object
- .sale_price_eur(boat) ⇒ Object
- .sale_price_rub(boat) ⇒ Object
-
.sale_price_usd(boat) ⇒ Object
–[sale]———————————————————————————————————-.
- .serialize(model, attributes: available_attributes, opts: {}) ⇒ Object
- .short_description(boat) ⇒ Object
- .state(boat) ⇒ Object
- .visits_today(boat) ⇒ Object
- .visits_total(boat) ⇒ Object
Methods inherited from AbstractSerializer
Class Method Details
.available_attributes ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/serializers/boat_serializer.rb', line 4 def available_attributes %i[ boat_beam_metrics boat_beam_metrics_ft boat_beam_metrics_meters boat_contacts boat_draft_metrics boat_draft_metrics_ft boat_draft_metrics_meters boat_hull_id boat_length_metrics boat_length_metrics_ft boat_length_metrics_meters boat_model boat_photos boat_type boat_type_id builder built_year charter_1_day_high_discount charter_1_day_high_eur charter_1_day_high_rub charter_1_day_high_usd charter_1_day_low_discount charter_1_day_low_eur charter_1_day_low_rub charter_1_day_low_usd charter_1_hour_high_discount charter_1_hour_high_eur charter_1_hour_high_rub charter_1_hour_high_usd charter_1_hour_low_discount charter_1_hour_low_eur charter_1_hour_low_rub charter_1_hour_low_usd charter_1_month_high_discount charter_1_month_high_eur charter_1_month_high_rub charter_1_month_high_usd charter_1_month_low_discount charter_1_month_low_eur charter_1_month_low_rub charter_1_month_low_usd charter_1_week_high_discount charter_1_week_high_eur charter_1_week_high_rub charter_1_week_high_usd charter_1_week_low_discount charter_1_week_low_eur charter_1_week_low_rub charter_1_week_low_usd crew_total guest_cabins guests_total hull_material id interior_designer latitude location_address longitude main_boat_photo_id motor name name_builder naval_architect per_season picture_medium_url price price_discount refit_year sale_price_discount sale_price_eur sale_price_rub sale_price_usd short_description state visits_today visits_total ].freeze end |
.boat_beam_metrics(boat) ⇒ Object
260 261 262 263 |
# File 'app/serializers/boat_serializer.rb', line 260 def boat_beam_metrics(boat) value = ::Lib::Boats::Dimensions.boatbeam(boat, @opts[:uom]) { boat_beam_metrics: value } end |
.boat_beam_metrics_ft(boat) ⇒ Object
265 266 267 |
# File 'app/serializers/boat_serializer.rb', line 265 def boat_beam_metrics_ft(boat) { boat_beam_metrics_ft: boat.boat_beam_metrics_ft } end |
.boat_beam_metrics_meters(boat) ⇒ Object
269 270 271 |
# File 'app/serializers/boat_serializer.rb', line 269 def boat_beam_metrics_meters(boat) { boat_beam_metrics_meters: boat.boat_beam_metrics_meters } end |
.boat_contacts(boat) ⇒ Object
Контакты владельцев: то, что приходит в boat_users_attributes из админской формы
460 461 462 463 464 465 466 467 |
# File 'app/serializers/boat_serializer.rb', line 460 def boat_contacts(boat) boat_contacts = boat.boat_users.map do |user| { user_id: user.user_id } end { boat_contacts: boat_contacts } end |
.boat_draft_metrics(boat) ⇒ Object
273 274 275 276 |
# File 'app/serializers/boat_serializer.rb', line 273 def boat_draft_metrics(boat) value = ::Lib::Boats::Dimensions.boatdraft(boat, @opts[:uom]) { boat_draft_metrics: value } end |
.boat_draft_metrics_ft(boat) ⇒ Object
278 279 280 |
# File 'app/serializers/boat_serializer.rb', line 278 def boat_draft_metrics_ft(boat) { boat_draft_metrics_ft: boat.boat_draft_metrics_ft } end |
.boat_draft_metrics_meters(boat) ⇒ Object
282 283 284 |
# File 'app/serializers/boat_serializer.rb', line 282 def boat_draft_metrics_meters(boat) { boat_draft_metrics_meters: boat.boat_draft_metrics_meters } end |
.boat_hull_id(boat) ⇒ Object
286 287 288 |
# File 'app/serializers/boat_serializer.rb', line 286 def boat_hull_id(boat) { boat_hull_id: boat.boat_hull_id } end |
.boat_length_metrics(boat) ⇒ Object
247 248 249 250 |
# File 'app/serializers/boat_serializer.rb', line 247 def boat_length_metrics(boat) value = ::Lib::Boats::Dimensions.boatlength(boat, @opts[:uom]) { boat_length_metrics: value } end |
.boat_length_metrics_ft(boat) ⇒ Object
256 257 258 |
# File 'app/serializers/boat_serializer.rb', line 256 def boat_length_metrics_ft(boat) { boat_length_metrics_ft: boat.boat_length_metrics_ft } end |
.boat_length_metrics_meters(boat) ⇒ Object
252 253 254 |
# File 'app/serializers/boat_serializer.rb', line 252 def boat_length_metrics_meters(boat) { boat_length_metrics_meters: boat.boat_length_metrics_meters } end |
.boat_model(boat) ⇒ Object
218 219 220 |
# File 'app/serializers/boat_serializer.rb', line 218 def boat_model(boat) { boat_model: boat.boat_model } end |
.boat_photos(boat) ⇒ Object
446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'app/serializers/boat_serializer.rb', line 446 def boat_photos(boat) # FIXME:: выяснить, нужно ли всётаки использовать .gsub('\'', ''') для строк с путями к фоткам? boat_photos = boat.boat_photos.map do |boat_photo| { id: boat_photo.id, gallery_path: boat_photo.picture.url(:gallery), medium_path: boat_photo.picture.url(:medium), thumb_path: boat_photo.picture.url(:thumb) } end { boat_photos: boat_photos } end |
.boat_type(boat) ⇒ Object
238 239 240 241 242 243 244 245 |
# File 'app/serializers/boat_serializer.rb', line 238 def boat_type(boat) { boat_type: { id: boat.boat_type_id, title: boat.boat_type&.name&.strip } } end |
.boat_type_id(boat) ⇒ Object
234 235 236 |
# File 'app/serializers/boat_serializer.rb', line 234 def boat_type_id(boat) { boat_type_id: boat.boat_type_id } end |
.builder(boat) ⇒ Object
152 153 154 |
# File 'app/serializers/boat_serializer.rb', line 152 def builder(boat) { builder: boat.builder&.strip } end |
.built_year(boat) ⇒ Object
209 210 211 |
# File 'app/serializers/boat_serializer.rb', line 209 def built_year(boat) { built_year: boat.built_year } end |
.charter_1_day_high_discount(boat) ⇒ Object
–[discount]——————————————————————————————————
406 407 408 |
# File 'app/serializers/boat_serializer.rb', line 406 def charter_1_day_high_discount(boat) { charter_1_day_high_discount: boat.charter_1_day_high_discount } end |
.charter_1_day_high_eur(boat) ⇒ Object
362 363 364 |
# File 'app/serializers/boat_serializer.rb', line 362 def charter_1_day_high_eur(boat) { charter_1_day_high_eur: boat.charter_1_day_high_eur } end |
.charter_1_day_high_rub(boat) ⇒ Object
358 359 360 |
# File 'app/serializers/boat_serializer.rb', line 358 def charter_1_day_high_rub(boat) { charter_1_day_high_rub: boat.charter_1_day_high_rub } end |
.charter_1_day_high_usd(boat) ⇒ Object
354 355 356 |
# File 'app/serializers/boat_serializer.rb', line 354 def charter_1_day_high_usd(boat) { charter_1_day_high_usd: boat.charter_1_day_high_usd } end |
.charter_1_day_low_discount(boat) ⇒ Object
410 411 412 |
# File 'app/serializers/boat_serializer.rb', line 410 def charter_1_day_low_discount(boat) { charter_1_day_low_discount: boat.charter_1_day_low_discount } end |
.charter_1_day_low_eur(boat) ⇒ Object
312 313 314 |
# File 'app/serializers/boat_serializer.rb', line 312 def charter_1_day_low_eur(boat) { charter_1_day_low_eur: boat.charter_1_day_low_eur } end |
.charter_1_day_low_rub(boat) ⇒ Object
308 309 310 |
# File 'app/serializers/boat_serializer.rb', line 308 def charter_1_day_low_rub(boat) { charter_1_day_low_rub: boat.charter_1_day_low_rub } end |
.charter_1_day_low_usd(boat) ⇒ Object
304 305 306 |
# File 'app/serializers/boat_serializer.rb', line 304 def charter_1_day_low_usd(boat) { charter_1_day_low_usd: boat.charter_1_day_low_usd } end |
.charter_1_hour_high_discount(boat) ⇒ Object
414 415 416 |
# File 'app/serializers/boat_serializer.rb', line 414 def charter_1_hour_high_discount(boat) { charter_1_hour_high_discount: boat.charter_1_hour_high_discount } end |
.charter_1_hour_high_eur(boat) ⇒ Object
350 351 352 |
# File 'app/serializers/boat_serializer.rb', line 350 def charter_1_hour_high_eur(boat) { charter_1_hour_high_eur: boat.charter_1_hour_high_eur } end |
.charter_1_hour_high_rub(boat) ⇒ Object
346 347 348 |
# File 'app/serializers/boat_serializer.rb', line 346 def charter_1_hour_high_rub(boat) { charter_1_hour_high_rub: boat.charter_1_hour_high_rub } end |
.charter_1_hour_high_usd(boat) ⇒ Object
–[high]———————————————————————————————————–
342 343 344 |
# File 'app/serializers/boat_serializer.rb', line 342 def charter_1_hour_high_usd(boat) { charter_1_hour_high_usd: boat.charter_1_hour_high_usd } end |
.charter_1_hour_low_discount(boat) ⇒ Object
418 419 420 |
# File 'app/serializers/boat_serializer.rb', line 418 def charter_1_hour_low_discount(boat) { charter_1_hour_low_discount: boat.charter_1_hour_low_discount } end |
.charter_1_hour_low_eur(boat) ⇒ Object
300 301 302 |
# File 'app/serializers/boat_serializer.rb', line 300 def charter_1_hour_low_eur(boat) { charter_1_hour_low_eur: boat.charter_1_hour_low_eur } end |
.charter_1_hour_low_rub(boat) ⇒ Object
296 297 298 |
# File 'app/serializers/boat_serializer.rb', line 296 def charter_1_hour_low_rub(boat) { charter_1_hour_low_rub: boat.charter_1_hour_low_rub } end |
.charter_1_hour_low_usd(boat) ⇒ Object
–[low]———————————————————————————————————–
292 293 294 |
# File 'app/serializers/boat_serializer.rb', line 292 def charter_1_hour_low_usd(boat) { charter_1_hour_low_usd: boat.charter_1_hour_low_usd } end |
.charter_1_month_high_discount(boat) ⇒ Object
422 423 424 |
# File 'app/serializers/boat_serializer.rb', line 422 def charter_1_month_high_discount(boat) { charter_1_month_high_discount: boat.charter_1_month_high_discount } end |
.charter_1_month_high_eur(boat) ⇒ Object
386 387 388 |
# File 'app/serializers/boat_serializer.rb', line 386 def charter_1_month_high_eur(boat) { charter_1_month_high_eur: boat.charter_1_month_high_eur } end |
.charter_1_month_high_rub(boat) ⇒ Object
382 383 384 |
# File 'app/serializers/boat_serializer.rb', line 382 def charter_1_month_high_rub(boat) { charter_1_month_high_rub: boat.charter_1_month_high_rub } end |
.charter_1_month_high_usd(boat) ⇒ Object
378 379 380 |
# File 'app/serializers/boat_serializer.rb', line 378 def charter_1_month_high_usd(boat) { charter_1_month_high_usd: boat.charter_1_month_high_usd } end |
.charter_1_month_low_discount(boat) ⇒ Object
426 427 428 |
# File 'app/serializers/boat_serializer.rb', line 426 def charter_1_month_low_discount(boat) { charter_1_month_low_discount: boat.charter_1_month_low_discount } end |
.charter_1_month_low_eur(boat) ⇒ Object
336 337 338 |
# File 'app/serializers/boat_serializer.rb', line 336 def charter_1_month_low_eur(boat) { charter_1_month_low_eur: boat.charter_1_month_low_eur } end |
.charter_1_month_low_rub(boat) ⇒ Object
332 333 334 |
# File 'app/serializers/boat_serializer.rb', line 332 def charter_1_month_low_rub(boat) { charter_1_month_low_rub: boat.charter_1_month_low_rub } end |
.charter_1_month_low_usd(boat) ⇒ Object
328 329 330 |
# File 'app/serializers/boat_serializer.rb', line 328 def charter_1_month_low_usd(boat) { charter_1_month_low_usd: boat.charter_1_month_low_usd } end |
.charter_1_week_high_discount(boat) ⇒ Object
430 431 432 |
# File 'app/serializers/boat_serializer.rb', line 430 def charter_1_week_high_discount(boat) { charter_1_week_high_discount: boat.charter_1_week_high_discount } end |
.charter_1_week_high_eur(boat) ⇒ Object
374 375 376 |
# File 'app/serializers/boat_serializer.rb', line 374 def charter_1_week_high_eur(boat) { charter_1_week_high_eur: boat.charter_1_week_high_eur } end |
.charter_1_week_high_rub(boat) ⇒ Object
370 371 372 |
# File 'app/serializers/boat_serializer.rb', line 370 def charter_1_week_high_rub(boat) { charter_1_week_high_rub: boat.charter_1_week_high_rub } end |
.charter_1_week_high_usd(boat) ⇒ Object
366 367 368 |
# File 'app/serializers/boat_serializer.rb', line 366 def charter_1_week_high_usd(boat) { charter_1_week_high_usd: boat.charter_1_week_high_usd } end |
.charter_1_week_low_discount(boat) ⇒ Object
434 435 436 |
# File 'app/serializers/boat_serializer.rb', line 434 def charter_1_week_low_discount(boat) { charter_1_week_low_discount: boat.charter_1_week_low_discount } end |
.charter_1_week_low_eur(boat) ⇒ Object
324 325 326 |
# File 'app/serializers/boat_serializer.rb', line 324 def charter_1_week_low_eur(boat) { charter_1_week_low_eur: boat.charter_1_week_low_eur } end |
.charter_1_week_low_rub(boat) ⇒ Object
320 321 322 |
# File 'app/serializers/boat_serializer.rb', line 320 def charter_1_week_low_rub(boat) { charter_1_week_low_rub: boat.charter_1_week_low_rub } end |
.charter_1_week_low_usd(boat) ⇒ Object
316 317 318 |
# File 'app/serializers/boat_serializer.rb', line 316 def charter_1_week_low_usd(boat) { charter_1_week_low_usd: boat.charter_1_week_low_usd } end |
.crew_total(boat) ⇒ Object
205 206 207 |
# File 'app/serializers/boat_serializer.rb', line 205 def crew_total(boat) { crew_total: boat.crew_total } end |
.default_opts ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'app/serializers/boat_serializer.rb', line 85 def default_opts { uom: 'ft', currency: 'USD', locale: 'en', is_for_rent: true } end |
.guest_cabins(boat) ⇒ Object
197 198 199 |
# File 'app/serializers/boat_serializer.rb', line 197 def guest_cabins(boat) { guest_cabins: boat.guest_cabins } end |
.guests_total(boat) ⇒ Object
193 194 195 |
# File 'app/serializers/boat_serializer.rb', line 193 def guests_total(boat) { guests_total: boat.guests_total } end |
.hull_material(boat) ⇒ Object
201 202 203 |
# File 'app/serializers/boat_serializer.rb', line 201 def hull_material(boat) { hull_material: boat.hull_material } end |
.id(boat) ⇒ Object
98 99 100 |
# File 'app/serializers/boat_serializer.rb', line 98 def id(boat) { id: boat.id } end |
.interior_designer(boat) ⇒ Object
102 103 104 |
# File 'app/serializers/boat_serializer.rb', line 102 def interior_designer(boat) { interior_designer: boat.interior_designer } end |
.latitude(boat) ⇒ Object
226 227 228 |
# File 'app/serializers/boat_serializer.rb', line 226 def latitude(boat) { latitude: boat.latitude } end |
.location_address(boat) ⇒ Object
222 223 224 |
# File 'app/serializers/boat_serializer.rb', line 222 def location_address(boat) { location_address: boat.location_address } end |
.longitude(boat) ⇒ Object
230 231 232 |
# File 'app/serializers/boat_serializer.rb', line 230 def longitude(boat) { longitude: boat.longitude } end |
.main_boat_photo_id(boat) ⇒ Object
144 145 146 147 148 149 150 |
# File 'app/serializers/boat_serializer.rb', line 144 def main_boat_photo_id(boat) boat_photo_id = if boat.boat_photo.present? boat.boat_photo.id end { main_boat_photo_id: boat_photo_id } end |
.motor(boat) ⇒ Object
140 141 142 |
# File 'app/serializers/boat_serializer.rb', line 140 def motor(boat) { motor: boat.motor } end |
.name(boat) ⇒ Object
136 137 138 |
# File 'app/serializers/boat_serializer.rb', line 136 def name(boat) { name: boat.name } end |
.name_builder(boat) ⇒ Object
Для страницы просмотра лодки
example: Carpe Diem by Lazzara example: Ismail
114 115 116 117 118 119 120 121 122 123 |
# File 'app/serializers/boat_serializer.rb', line 114 def name_builder(boat) arr = [] arr << boat.name&.strip if boat.builder.present? arr << I18n.t('boat.builder.prefix') arr << boat.builder.strip end { name_builder: arr * ' ' } end |
.naval_architect(boat) ⇒ Object
106 107 108 |
# File 'app/serializers/boat_serializer.rb', line 106 def naval_architect(boat) { naval_architect: boat.naval_architect } end |
.per_season(boat) ⇒ Object
per day, per week; в день, в час, за месяц;
163 164 165 166 167 168 169 170 |
# File 'app/serializers/boat_serializer.rb', line 163 def per_season(boat) season_key = ::Lib::Boats::RentPricePerSeason.spot_rentprice_id(boat, @opts[:currency], @opts[:rent_price_id]).gsub(/_low|_high/, '') #=> charter_1_week_low, charter_1_day_high translate = I18n.t("boat.rent_price.per_#{season_key}") value = @opts[:is_for_rent] ? translate : '' { per_season: value } end |
.picture_medium_url(boat) ⇒ Object
noinspection RubyResolve
126 127 128 129 130 131 132 133 134 |
# File 'app/serializers/boat_serializer.rb', line 126 def picture_medium_url(boat) url = if boat.boat_photo.present? boat.boat_photo.picture.url(:medium) else '' end { picture_medium_url: url } end |
.price(boat) ⇒ Object
₽ 293,885
173 174 175 176 177 178 179 180 181 |
# File 'app/serializers/boat_serializer.rb', line 173 def price(boat) value = if @opts[:is_for_rent] ::Lib::Boats::RentPricePerSeason.price(boat, @opts[:currency], @opts[:rent_price_id]) else ::Lib::Boats::SalePrice.price(boat, @opts[:currency]) end { price: value } end |
.price_discount(boat) ⇒ Object
12%
184 185 186 187 188 189 190 191 |
# File 'app/serializers/boat_serializer.rb', line 184 def price_discount(boat) value = if @opts[:is_for_rent] ::Lib::Boats::RentPricePerSeason.price_discount(boat, @opts[:currency]) else ::Lib::Boats::SalePrice.price_discount(boat) end { price_discount: value } end |
.refit_year(boat) ⇒ Object
213 214 215 216 |
# File 'app/serializers/boat_serializer.rb', line 213 def refit_year(boat) value = boat.refit_year { refit_year: value } end |
.sale_price_discount(boat) ⇒ Object
438 439 440 |
# File 'app/serializers/boat_serializer.rb', line 438 def sale_price_discount(boat) { sale_price_discount: boat.sale_price_discount } end |
.sale_price_eur(boat) ⇒ Object
400 401 402 |
# File 'app/serializers/boat_serializer.rb', line 400 def sale_price_eur(boat) { sale_price_eur: boat.sale_price_eur } end |
.sale_price_rub(boat) ⇒ Object
396 397 398 |
# File 'app/serializers/boat_serializer.rb', line 396 def sale_price_rub(boat) { sale_price_rub: boat.sale_price_rub } end |
.sale_price_usd(boat) ⇒ Object
–[sale]———————————————————————————————————-
392 393 394 |
# File 'app/serializers/boat_serializer.rb', line 392 def sale_price_usd(boat) { sale_price_usd: boat.sale_price_usd } end |
.serialize(model, attributes: available_attributes, opts: {}) ⇒ Object
94 95 96 |
# File 'app/serializers/boat_serializer.rb', line 94 def serialize(model, attributes: available_attributes, opts: {}) super(model, attributes: attributes, opts: default_opts.merge(opts)) end |
.short_description(boat) ⇒ Object
156 157 158 159 160 |
# File 'app/serializers/boat_serializer.rb', line 156 def short_description(boat) attr = 'short_description_%s' % @opts[:locale] value = boat.send(attr.to_sym) { short_description: value } end |
.state(boat) ⇒ Object
442 443 444 |
# File 'app/serializers/boat_serializer.rb', line 442 def state(boat) { state: boat.state } end |
.visits_today(boat) ⇒ Object
469 470 471 |
# File 'app/serializers/boat_serializer.rb', line 469 def visits_today(boat) { visits_today: boat.visits_today } end |
.visits_total(boat) ⇒ Object
473 474 475 |
# File 'app/serializers/boat_serializer.rb', line 473 def visits_total(boat) { visits_total: boat.visits_total } end |