Sha256: d08048bfcf90d0c2a060f798200230b7c84303cce9ff72ed224b98f8d1c0c7f5
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require_relative 'observable' require_relative 'observer' class WidgetBinding include Glimmer include Observable include Observer attr_reader :widget, :property @@property_type_converters = { :text => Proc.new { |value| value.to_s }, :items => Proc.new { |value| value.to_java :string}, :visible => Proc.new { |value| !!value} } def initialize(model, property, translator = nil) @widget = model @property = property @translator = translator || proc {|value| value} add_contents(@widget) { on_widget_disposed { |dispose_event| unregister_all_observables } } end def update(value) converted_value = translated_value = @translator.call(value) converter = @@property_type_converters[@property.to_sym] converted_value = converter.call(translated_value) if converter @widget.widget.send("set#{@property.camelcase(:upper)}", converted_value) unless evaluate_property == converted_value end def evaluate_property @widget.widget.send(@property) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
glimmer-0.3.2 | lib/command_handlers/models/widget_binding.rb |