Skip to content

Commit

Permalink
fix: Hides the Map portion of ModelCounter and ModelTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Dec 18, 2022
1 parent 9733261 commit d125bb0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/katana_model/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.3.12"
version: "1.3.13"
lints:
dependency: transitive
description:
Expand Down
25 changes: 17 additions & 8 deletions packages/katana_model/lib/src/model_field_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ extension DynamicMapModelFieldValueExtensions on DynamicMap {
///
/// これをサーバーに渡すことで安定して値の増減を行うことができます。
@immutable
class ModelCounter extends ModelFieldValue<int>
with ModelFieldValueAsMapMixin<int> {
class ModelCounter extends ModelFieldValue<int> {
/// Define the field as a counter.
///
/// The base value is given as [value], and the value is increased or decreased by [increment].
Expand All @@ -328,9 +327,7 @@ class ModelCounter extends ModelFieldValue<int>
/// ベースの値を[value]として与え、[increment]で値を増減していきます。
///
/// これをサーバーに渡すことで安定して値の増減を行うことができます。
const ModelCounter(int value)
: _value = value,
_increment = 0;
const factory ModelCounter(int value) = _ModelCounter;

/// Convert from [json] map to [ModelCounter].
///
Expand Down Expand Up @@ -391,6 +388,11 @@ class ModelCounter extends ModelFieldValue<int>
int get hashCode => _value.hashCode ^ _increment.hashCode;
}

@immutable
class _ModelCounter extends ModelCounter with ModelFieldValueAsMapMixin<int> {
const _ModelCounter(int value) : super._(value, 0);
}

/// Define the field as a timestamp.
///
/// The base value is given as [value]. If not given, the current time is set.
Expand All @@ -403,8 +405,7 @@ class ModelCounter extends ModelFieldValue<int>
///
/// これをサーバーに渡すことでサーバー側のタイムスタンプがデータとして保存されます。
@immutable
class ModelTimestamp extends ModelFieldValue<DateTime>
with ModelFieldValueAsMapMixin<DateTime> {
class ModelTimestamp extends ModelFieldValue<DateTime> {
/// Define the field as a timestamp.
///
/// The base value is given as [value]. If not given, the current time is set.
Expand All @@ -416,7 +417,7 @@ class ModelTimestamp extends ModelFieldValue<DateTime>
/// ベースの値を[value]として与えます。与えられなかった場合現在時刻がセットされます。
///
/// これをサーバーに渡すことでサーバー側のタイムスタンプがデータとして保存されます。
const ModelTimestamp([DateTime? value]) : _value = value;
const factory ModelTimestamp([DateTime? value]) = _ModelTimestamp;

/// Convert from [json] map to [ModelTimestamp].
///
Expand All @@ -429,6 +430,8 @@ class ModelTimestamp extends ModelFieldValue<DateTime>
return ModelTimestamp(DateTime.fromMillisecondsSinceEpoch(timestamp));
}

const ModelTimestamp._([DateTime? value]) : _value = value;

/// A string of type [ModelTimestamp].
///
/// [ModelTimestamp]のタイプの文字列。
Expand Down Expand Up @@ -457,3 +460,9 @@ class ModelTimestamp extends ModelFieldValue<DateTime>
@override
int get hashCode => _value.hashCode;
}

@immutable
class _ModelTimestamp extends ModelTimestamp
with ModelFieldValueAsMapMixin<DateTime> {
const _ModelTimestamp([DateTime? value]) : super._(value);
}
8 changes: 4 additions & 4 deletions packages/katana_model_firestore/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,21 @@ packages:
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.10"
version: "0.15.10+1"
katana_firebase:
dependency: "direct main"
description:
name: katana_firebase
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
version: "1.1.4"
katana_model:
dependency: "direct main"
description:
name: katana_model
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.8"
version: "1.3.13"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -454,7 +454,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.2"
version: "3.1.3"
xdg_directories:
dependency: transitive
description:
Expand Down

0 comments on commit d125bb0

Please sign in to comment.