Skip to content

Commit

Permalink
Adds rules extension on Object; Allow passing in RulesIterable to Rul…
Browse files Browse the repository at this point in the history
…esSet methods
  • Loading branch information
Rexios80 committed Aug 2, 2023
1 parent d26adc8 commit 18e95b9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions firebase_rules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.2
- Adds extension on `Object` to allow converting any `Object` to a `RulesMap<String, dynamic>`
- The `RulesSet` methods `hasAll`, `hasAny`, `hasOnly` now accept either a `RulesSet` or `RulesList`

## 0.1.1
- Adds extension to `DateTime` to allow access to `RulesTimestamp` methods

Expand Down
6 changes: 6 additions & 0 deletions firebase_rules/lib/src/firebase/namespace/convert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ extension RulesStringExtension on String {
/// Access to [RulesString] methods
RulesString rules() => throw UnimplementedError();
}

/// Convert any [Object] to a [RulesMap]
extension RulesObjectExtension on Object {
/// Convert any [Object] to a [RulesMap]
RulesMap<String, dynamic> rules() => throw UnimplementedError();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// Base class for RulesSet and RulesList
abstract class RulesIterable<T> {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:firebase_rules/src/firebase/namespace/model/model.dart';
import 'package:firebase_rules/src/firebase/namespace/model/src/iterable.dart';

/// List type. Items are not necessarily homogenous.
abstract class RulesList<T> {
abstract class RulesList<T> extends RulesIterable<T> {
RulesList._();

/// Index operator, get value index i
Expand Down
10 changes: 6 additions & 4 deletions firebase_rules/lib/src/firebase/namespace/model/src/set.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:firebase_rules/src/firebase/namespace/model/src/iterable.dart';

/// A set is an unordered collection. A set cannot contain duplicate items.
abstract class RulesSet<T> {
abstract class RulesSet<T> extends RulesIterable<T> {
RulesSet._();

/// Check if value v exists in set x.
Expand All @@ -14,15 +16,15 @@ abstract class RulesSet<T> {

/// Test whether the set calling hasAll() contains all of the items in the
/// comparison set passed to hasAll().
bool hasAll(RulesSet<T> other);
bool hasAll(RulesIterable<T> other);

/// Test whether the set calling hasAny() contains any of the items in the set
/// or list passed to hasAny().
bool hasAny(RulesSet<T> other);
bool hasAny(RulesIterable<T> other);

/// Test whether the set calling hasOnly() contains only the items in the
/// comparison set or list passed to hasOnly().
bool hasOnly(RulesSet<T> other);
bool hasOnly(RulesIterable<T> other);

/// Returns a set that is the intersection between the set calling
/// intersection() and the set passed to intersection(). That is, returns a
Expand Down
2 changes: 1 addition & 1 deletion firebase_rules/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firebase_rules
description: A type-safe Firebase rules generator for Firestore, Storage, and Realtime Database
version: 0.1.1
version: 0.1.2
homepage: https://github.com/IO-Design-Team/firebase_rules/tree/master/firebase_rules

environment:
Expand Down

0 comments on commit 18e95b9

Please sign in to comment.