lib/motion/util.rb in rm-extensions-0.1.8 vs lib/motion/util.rb in rm-extensions-0.1.9
- old
+ new
@@ -16,9 +16,22 @@
# Good for development and experimenting.
def rmext_assert_main_thread!
raise "This method must be called on the main thread." unless NSThread.currentThread.isMainThread
end
+ # Shortcut to instance_variable_get and instance_variable_get:
+ # 1 arg for instance_variable_get
+ # 2 args for instance_variable_set
+ def rmext_ivar(*args)
+ if args.size == 1
+ instance_variable_get("@#{args[0]}")
+ elsif args.size == 2
+ instance_variable_set("@#{args[0]}", args[1])
+ else
+ raise "rmext_ivar called with invalid arguments: #{args.inspect}"
+ end
+ end
+
end
end
end