lib/checkpoint/resource.rb in checkpoint-1.1.0 vs lib/checkpoint/resource.rb in checkpoint-1.1.1
- old
+ new
@@ -52,10 +52,18 @@
# @return [AllOfAnyType] a wildcard resource instance
def self.all
AllOfAnyType.new
end
+ # Test whether this Resource represents all entities of all types.
+ #
+ # @see {::all}
+ # @return [Boolean] true if this is a universal wildcard
+ def all?
+ type == ALL && id == ALL
+ end
+
# Convert this object to a Resource.
#
# For Checkpoint-supplied Resources, this is an identity operation,
# but it allows consistent handling of the built-in types and
# application-supplied types that will either implement this interface or
@@ -113,9 +121,17 @@
#
# @see Resource::AllOfType
# @return [Resource] A Resource of the same type, but for all members
def all_of_type
Resource::AllOfType.new(type)
+ end
+
+ # Test whether this is a Resource wildcard of some specific type.
+ #
+ # @return [Boolean] true if this Resource has a specific type, but
+ # has the any/all ID, representing any Resources of that type
+ def all_of_type?
+ type != ALL && id == ALL
end
# Check whether two Resources refer to the same entity.
# @param other [Resource] Another Resource to compare with
# @return [Boolean] true when the other Resource's entity is the same as