jrubyfx
jrubyfx copied to clipboard
Enhancement: Provide Ruby binding impls
java_import Java::javafx.beans.binding.StringBinding
class RubyStringBinding < StringBinding
def initialize(property:, method:)
super()
@property, @method = property, method
bind @property
end
def computeValue
property_value = @property.get
return unless property_value
property_value.__send__ @method
end
end
The Java bindings provided from Bindings assumes Java reflective lookup so they cannot see our Ruby methods...
I should also point out that StringBinding is just some convenience methods on a type-erased type.
abstract StringBinding implements Binding<String>
so I think we can make a single binding to rule them all but we might not be able to leverage one of their abstract classes (unsure about that).