Module: AzaharaSchemaCurrency::PresenterPatch

Defined in:
lib/azahara_schema_currency/presenter_patch.rb

Instance Method Summary collapse

Instance Method Details

#format_value_html(attribute, unformated_value, **options) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/azahara_schema_currency/presenter_patch.rb', line 4

def format_value_html(attribute, unformated_value, **options)
  case attribute.type
  when 'currency'
    Money.from_amount(unformated_value, options[:currency_code].to_s.upcase.presence).format
  else
    super
  end
end

#formatting_options(attribute, entity) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/azahara_schema_currency/presenter_patch.rb', line 14

def formatting_options(attribute, entity)
  case attribute.type
  when 'currency'
    {currency_code: attribute.currency_code(entity).to_s}
  else
    super
  end
end