jrubyfx icon indicating copy to clipboard operation
jrubyfx copied to clipboard

Enhancement: Provide Ruby binding impls

Open enebo opened this issue 8 years ago • 1 comments

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...

enebo avatar Mar 13 '17 15:03 enebo

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).

enebo avatar Mar 13 '17 16:03 enebo