mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
These config values are relatively static but in some cases they can be called many times in the same request (like rendering a report or a large list of line_items in BOM). These values will now only get fetched from Redis/Postgres once at most per request/job.
26 lines
518 B
Ruby
26 lines
518 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Api::CurrencyConfigSerializer < ActiveModel::Serializer
|
|
attributes :currency, :display_currency, :symbol, :symbol_position, :hide_cents
|
|
|
|
def currency
|
|
CurrentConfig.get(:currency)
|
|
end
|
|
|
|
def display_currency
|
|
CurrentConfig.get(:display_currency)
|
|
end
|
|
|
|
def symbol
|
|
::Money.new(1, CurrentConfig.get(:currency)).symbol
|
|
end
|
|
|
|
def symbol_position
|
|
CurrentConfig.get(:currency_symbol_position)
|
|
end
|
|
|
|
def hide_cents
|
|
CurrentConfig.get(:hide_cents)
|
|
end
|
|
end
|