Sha256: f766a8f717f61d1a6a680aee9e8bed6905c9992ee8257c04f20364cbc19a566f

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 KB

Contents

## Upgrading to v1.0

In an initializer add the following
```ruby
Money.configure do |config|
  config.legacy_default_currency!
  config.legacy_deprecations!
  config.legacy_json_format!
  #...
end
```

Remove each legacy setting making sure your app functions as expected.

Replace `Money.parse` with `Money::Parser::Fuzzy.parse`.

### Legacy support

#### legacy_default_currency!

By enabling this setting your app will accept money object that are missing a currency

```ruby
Money.new(1) #=> value: 1, currency: XXX
```

#### legacy_deprecations!

invalid money values return zero
```ruby
Money.new('a', 'USD') #=> Money.new(0, 'USD')
```

invalid currency is ignored
```ruby
Money.new(1, 'ABCD') #=> Money.new(1)
```

mathematical operations between objects are allowed
```ruby
Money.new(1, 'USD') + Money.new(1, 'CAD') #=> Money.new(2, 'USD')
```

parsing a string with invalid delimiters
```ruby
Money.parse('123*12') #=> Money.new(123)
```

#### legacy_json_format!

to_json will return only the value (no currency)
```ruby
# with legacy_json_format!
money.to_json #=> "1"

# without
money.to_json #=> { value: 1, currency: 'USD' }
```

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
shopify-money-3.0.0 UPGRADING.md
shopify-money-2.2.2 UPGRADING.md
shopify-money-2.2.1 UPGRADING.md
shopify-money-2.2.0 UPGRADING.md
shopify-money-2.0.0 UPGRADING.md
shopify-money-1.3.0 UPGRADING.md
shopify-money-1.2.1 UPGRADING.md
shopify-money-1.2.0 UPGRADING.md
shopify-money-1.1.2 UPGRADING.md
shopify-money-1.1.1 UPGRADING.md
shopify-money-1.1.0 UPGRADING.md
shopify-money-1.0.2.pre UPGRADING.md