Class: WidgetBinding
- Inherits:
-
Object
- Object
- WidgetBinding
- Includes:
- Observer
- Defined in:
- lib/command_handlers/models/widget_binding.rb
Constant Summary collapse
- @@property_type_converters =
{ :text => Proc.new { |value| value.to_s }, :items => Proc.new { |value| value.to_java :string} }
Instance Attribute Summary collapse
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#widget ⇒ Object
readonly
Returns the value of attribute widget.
Instance Method Summary collapse
- #evaluate_property ⇒ Object
-
#initialize(model, property, translator = nil) ⇒ WidgetBinding
constructor
A new instance of WidgetBinding.
- #update(value) ⇒ Object
Constructor Details
#initialize(model, property, translator = nil) ⇒ WidgetBinding
Returns a new instance of WidgetBinding.
11 12 13 14 15 |
# File 'lib/command_handlers/models/widget_binding.rb', line 11 def initialize(model, property, translator = nil) = model @property = property @translator = translator || proc {|value| value} end |
Instance Attribute Details
#property ⇒ Object (readonly)
Returns the value of attribute property.
6 7 8 |
# File 'lib/command_handlers/models/widget_binding.rb', line 6 def property @property end |
#widget ⇒ Object (readonly)
Returns the value of attribute widget.
6 7 8 |
# File 'lib/command_handlers/models/widget_binding.rb', line 6 def end |
Instance Method Details
#evaluate_property ⇒ Object
22 23 24 |
# File 'lib/command_handlers/models/widget_binding.rb', line 22 def evaluate_property ..send(@property) end |
#update(value) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/command_handlers/models/widget_binding.rb', line 16 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 ..send("set#{@property.camelcase(:upper)}", converted_value) unless evaluate_property == converted_value end |