mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Simplified use of ValueObject in OfferRepository
I don't think we need to instantiate and use the `equals` method here. It adds an extra dependency to the Repository implementation, but it is slightly more "correct" as it means that we leak internals by comparing strings exactly? The ValueObject pattern here was very much a trial and isn't something we're necessarily sticking with, so I don't see a problem with this string comparison.
This commit is contained in:
parent
a97383f2de
commit
00072a204f
1 changed files with 1 additions and 2 deletions
|
@ -2,7 +2,6 @@ const {flowRight} = require('lodash');
|
||||||
const {mapKeyValues, mapQuery} = require('@tryghost/mongo-utils');
|
const {mapKeyValues, mapQuery} = require('@tryghost/mongo-utils');
|
||||||
const DomainEvents = require('@tryghost/domain-events');
|
const DomainEvents = require('@tryghost/domain-events');
|
||||||
const Offer = require('../domain/models/Offer');
|
const Offer = require('../domain/models/Offer');
|
||||||
const OfferStatus = require('../domain/models/OfferStatus');
|
|
||||||
|
|
||||||
const statusTransformer = mapKeyValues({
|
const statusTransformer = mapKeyValues({
|
||||||
key: {
|
key: {
|
||||||
|
@ -197,7 +196,7 @@ class OfferRepository {
|
||||||
duration: offer.duration.value.type,
|
duration: offer.duration.value.type,
|
||||||
duration_in_months: offer.duration.value.type === 'repeating' ? offer.duration.value.months : null,
|
duration_in_months: offer.duration.value.type === 'repeating' ? offer.duration.value.months : null,
|
||||||
currency: offer.currency ? offer.currency.value : null,
|
currency: offer.currency ? offer.currency.value : null,
|
||||||
active: offer.status.equals(OfferStatus.create('active'))
|
active: offer.status.value === 'active'
|
||||||
};
|
};
|
||||||
|
|
||||||
if (offer.isNew) {
|
if (offer.isNew) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue