lib/myrrha.rb in myrrha-1.1.0 vs lib/myrrha.rb in myrrha-1.2.0
- old
+ new
@@ -16,12 +16,12 @@
# @return [Class] the created domain
#
def self.domain(superdom = Object, subdoms=nil, &pred)
dom = Class.new(superdom).extend(Domain)
dom.instance_eval {
- @sub_domains = subdoms
- @super_domain = superdom
+ @subdomains = subdoms
+ @superdomain = superdom
@predicate = pred
}
dom
end
@@ -64,25 +64,32 @@
end
end
# (see Class.superclass)
def superclass
- @super_domain
+ superdomain || super
end
#
- # Checks if `value` belongs to this domain
- #
- def ===(value)
- (superclass === value) && @predicate.call(value)
+ # Returns the super domain if installed
+ #
+ def superdomain
+ @superdomain
end
#
# Returns true if clazz if an explicit sub domain of self or if it's the
# case in Ruby.
#
def superdomain_of?(child)
- Array(@sub_domains).include?(child)
+ Array(@subdomains).include?(child)
+ end
+
+ #
+ # Checks if `value` belongs to this domain
+ #
+ def ===(value)
+ (superclass === value) && predicate.call(value)
end
#
# Returns the specialization by constraint predicate
#
\ No newline at end of file