Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HEH. Solution in Ruby #2

Open
enebo opened this issue Mar 13, 2017 · 2 comments
Open

HEH. Solution in Ruby #2

enebo opened this issue Mar 13, 2017 · 2 comments

Comments

@enebo
Copy link

enebo commented Mar 13, 2017

Sorry I was on multiple machines and I turned off the one I was working on before I realized I could have submitted a PR (and you were not on IRC):

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

So this works fine and you adapter this pattern for all basic types of Binding (although to be honest with type erasure you can probably use this class for any Java type since they all end up as Object).

@enebo
Copy link
Author

enebo commented Mar 13, 2017

Added jruby/jrubyfx#112 on making this more general and adding it to jrubyfx. Thanks for bringing this to our attention.

@stergiom
Copy link
Owner

Worked like a charm 🍀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants