lib/object.fy in fancy-0.6.0 vs lib/object.fy in fancy-0.7.0
- old
+ new
@@ -288,17 +288,20 @@
"""
cond if_true: else_block else: block
}
+ alias_method: 'unless:then: for: 'unless:do:
+ alias_method: 'unless:then:else: for: 'unless:do:else:
+
def method: method_name {
"""
@return @Method@ with @method_name defined for @self, or @nil.
Returns the method with a given name for self, if defined.
"""
- method(message_name: method_name)
+ method(method_name message_name)
}
def documentation {
"""
@return @Fancy::Documentation@ object for @self.
@@ -569,9 +572,32 @@
slots map: |s| {
get_slot: s
}
}
+
+ def with_mutable_slots: slotnames do: block {
+ """
+ @slotnames @Fancy Enumerable@ of slotnames to be mutable within @block.
+ @block @Block@ to be called with @self.
+
+ Calls @block with @self while having slots defined in @slotnames
+ be mutable during execution of @block.
+ """
+
+ metaclass read_write_slots: slotnames
+ val = nil
+ try {
+ val = block call: [self]
+ } finally {
+ slotnames each: |s| {
+ metaclass undefine_method: s
+ metaclass undefine_method: "#{s}:"
+ }
+ return val
+ }
+ }
+ private: 'with_mutable_slots:do:
def <=> other {
"""
@other Other object to compare against.
@return -1 if @self is smaller, 0 if @self is equal or 1 if @self is greater or equal compared to @other.
\ No newline at end of file