Skip to content

Commit 3ed2d61

Browse files
committed
Add Currency#initialize taking named arguments for all properties
1 parent 4ebdc5e commit 3ed2d61

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ To define a new `Money::Currency` use `Money::Currency.register` as shown
101101
below.
102102

103103
```crystal
104-
currency = Money::Currency.from_json({
104+
currency = Money::Currency.new(
105105
priority: 1,
106106
code: "USD",
107107
iso_numeric: 840,
@@ -112,7 +112,7 @@ currency = Money::Currency.from_json({
112112
subunit_to_unit: 100,
113113
decimal_mark: ".",
114114
thousands_separator: ","
115-
}.to_json)
115+
)
116116
117117
Money::Currency.register(currency)
118118
```

src/money/currency.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct Money
7171
wrap?(value) || raise UnknownCurrencyError.new("Can't find currency: #{value}")
7272
end
7373

74-
def initialize(@code, @subunit_to_unit)
74+
def initialize(*, @priority = nil, @iso_numeric = nil, @code, @name = nil, @symbol = nil, @alternate_symbols = nil, @subunit = nil, @subunit_to_unit, @symbol_first = nil, @html_entity = nil, @decimal_mark = nil, @thousands_separator = nil, @smallest_denomination = nil)
7575
end
7676

7777
# Returns the relation between subunit and unit as a base 10 exponent.

0 commit comments

Comments
 (0)