Skip to content

Commit

Permalink
Add Currency#initialize taking named arguments for all properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Apr 17, 2023
1 parent 4ebdc5e commit 3ed2d61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ To define a new `Money::Currency` use `Money::Currency.register` as shown
below.

```crystal
currency = Money::Currency.from_json({
currency = Money::Currency.new(
priority: 1,
code: "USD",
iso_numeric: 840,
Expand All @@ -112,7 +112,7 @@ currency = Money::Currency.from_json({
subunit_to_unit: 100,
decimal_mark: ".",
thousands_separator: ","
}.to_json)
)
Money::Currency.register(currency)
```
Expand Down
2 changes: 1 addition & 1 deletion src/money/currency.cr
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct Money
wrap?(value) || raise UnknownCurrencyError.new("Can't find currency: #{value}")
end

def initialize(@code, @subunit_to_unit)
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)
end

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

0 comments on commit 3ed2d61

Please sign in to comment.