Method: JRubyFX#with

Defined in:
lib/jrubyfx/fxml_module.rb

#with(obj, properties = {}, &block) ⇒ Object

call-seq:

with(obj, hash) => obj
with(obj) { block } => obj
with(obj, hash) { block }=> obj

Set properties (e.g. setters) on the passed in object plus also invoke any block passed against this object.

Examples

with(grid, vgap: 2, hgap: 2) do
  set_pref_size(500, 400)
  children << location << go << view
end


42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/jrubyfx/fxml_module.rb', line 42

def with(obj, properties = {}, &block)
  populate_properties(obj, properties)

  if block_given?
    # cache the proxy - http://wiki.jruby.org/Persistence
    obj.class.__persistent__ = true if obj.class.ancestors.include? JavaProxy
    obj.extend(JRubyFX)
    obj.instance_eval(&block)
  end
  
  obj
end