我目前的配置格式似乎很冗余。我怎么能把它转换成下一个预期的配置格式?我如何删除Ruby DSL中的重复部分
我预期的配置是:
MoneyRails.configure do |config|
register_currency("TWD", 100)
register_currency("USD", 100)
....
end
我现在的配置是:
MoneyRails.configure do |config|
config.register_currency = {
:priority => 1,
:iso_code => "TWD",
:name => "TWD",
:symbol => "NT$ ",
:symbol_first => true,
:subunit => "Subcent",
:subunit_to_unit => 100,
:thousands_separator => ",",
:decimal_mark => "."
}
config.register_currency = {
:priority => 1,
:iso_code => "USD",
:name => "USD",
:symbol => "$ ",
:symbol_first => true,
:subunit => "Subcent",
:subunit_to_unit => 100,
:thousands_separator => ",",
:decimal_mark => "."
}
config.register_currency = {
:priority => 1,
:iso_code => "SGD",
:name => "SGD",
:symbol => "$ ",
:symbol_first => true,
:subunit => "Subcent",
:subunit_to_unit => 100,
:thousands_separator => ",",
:decimal_mark => "."
}
config.register_currency = {
:priority => 1,
:iso_code => "THB",
:name => "THB",
:symbol => "$ ",
:symbol_first => true,
:subunit => "Subcent",
:subunit_to_unit => 100,
:thousands_separator => ",",
:decimal_mark => "."
}
config.register_currency = {
:priority => 1,
:iso_code => "AUD",
:name => "AUD",
:symbol => "$ ",
:symbol_first => true,
:subunit => "Subcent",
:subunit_to_unit => 100,
:thousands_separator => ",",
:decimal_mark => "."
}
config.register_currency = {
:priority => 1,
:iso_code => "KRW",
:name => "KRW",
:symbol => "$ ",
:symbol_first => true,
:subunit => "Subcent",
:subunit_to_unit => 100,
:thousands_separator => ",",
:decimal_mark => "."
}
...
end
欢迎来到Stack Overflow。当你试图从目前的版本降低到你想要的版本时会发生什么?我没有看到任何问题,只是一个愿望清单。我们希望看到您试图做的事以及您为何无法正常工作的解释。 –