Skip to content

Instantly share code, notes, and snippets.

View jorgenpt's full-sized avatar

Jørgen Tjernø jorgenpt

View GitHub Profile
@jorgenpt
jorgenpt / objc_calling.rb
Created November 3, 2011 08:15
Objective-C-esque calling convention in Ruby (or: Why I shouldn't be let near method_missing)
# See the bottom of the file for how this actually works.
module ObjC
def method_missing(method, *args)
ObjCCall.new(self, [], []).send(method, *args)
end
end
class ObjCCall
def initialize(obj, selector, args)
public FormValidation doCheckOsVersion(@QueryParameter String value) {
return doCheckOsVersion(value, true).getFormValidation();
}
private ValidationResult doCheckOsVersion(String osVersion, boolean allowVariables) {
if (osVersion == null || osVersion.equals("")) {
return ValidationResult.error(Messages.OS_VERSION_REQUIRED());
}
if (!allowVariables && osVersion.matches(Constants.REGEX_VARIABLE)) {
return ValidationResult.error(Messages.INVALID_OS_VERSION());
Oct 25, 2011 6:54:42 PM hudson.ExpressionFactory2$JexlExpression evaluate
WARNING: Caught exception evaluating: descriptor.getPropertyType(instance,field).itemTypeDescriptorOrDie. Reason: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.jexl.util.PropertyExecutor.execute(PropertyExecutor.java:125)
at org.apache.commons.jexl.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:314)
at org.apache.commons.jexl.parser.ASTArrayAccess.evaluateExpr(ASTArrayAccess.java:185)
@jorgenpt
jorgenpt / lazyobject.rb
Created February 27, 2011 06:19
Create on use
# Class to easily instantiate an object when needed.
# Similar to using (object ||= Foo.new).bar, but stores the initialization code to make
# the code cleaner.
class LazyObject
@object = nil
def initialize(&code)
@init = code
end
def was_initialized?