lib/sugarcube-anonymous/anonymous.rb in sugarcube-0.20.1 vs lib/sugarcube-anonymous/anonymous.rb in sugarcube-0.20.3
- old
+ new
@@ -24,29 +24,44 @@
def method_missing(symbol, *args)
if args.size == 0
key = symbol
key = symbol.to_s unless self.include? key
if self.include?(key)
+ self[key] = self[key].to_object
return self[key]
end
elsif args.size == 1 && /(.*)=$/ =~ symbol.to_s
key = $1.to_sym
key = key.to_s unless self.include? key
if self.include?(key)
- return self[key] = args.first
+ return self[key] = args.first.to_object
end
end
return super
end
def to_object
self
end
+ # replace enumerable methods
+ alias :anonymous_each :each
+
+ def each
+ anonymous_each {|k,v| yield k, v.to_object}
+ end
+
end
end
+class NSObject
+
+ def to_object
+ self
+ end
+
+end
class NSDictionary
def to_object
SugarCube::Anonymous[self]