Class: Stick::Units::CurrencyLoader
- Defined in:
- lib/stick/units/currency.rb
Constant Summary collapse
- THREAD_REFERENCE =
'Units::ce_service'.to_sym
Instance Method Summary collapse
Methods inherited from Loader
Instance Method Details
#ce_service(converter, name, &blk) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/stick/units/currency.rb', line 12 def ce_service(converter, name, &blk) old_service = Thread.current[THREAD_REFERENCE] Thread.current[THREAD_REFERENCE] = Units::Converter::ExchangeRate.const_get(name) yield ensure Thread.current[THREAD_REFERENCE] = old_service end |
#currency_unit(converter, name) ⇒ Object
20 21 22 23 |
# File 'lib/stick/units/currency.rb', line 20 def currency_unit(converter, name) service = Thread.current[THREAD_REFERENCE] || Units::Config::DEFAULT_CURRENCY_SERVICE converter.send(:register_unit, name, :equals => service.create_conversion(name, converter)) end |