Class: Freightrain::FreightBinding
- Inherits:
-
Object
- Object
- Freightrain::FreightBinding
- Defined in:
- lib/freightrain/binding/freight_binding.rb
Instance Attribute Summary collapse
-
#data_source ⇒ Object
Returns the value of attribute data_source.
Instance Method Summary collapse
- #commit ⇒ Object
-
#initialize(widget, options) ⇒ FreightBinding
constructor
A new instance of FreightBinding.
- #update ⇒ Object
Constructor Details
#initialize(widget, options) ⇒ FreightBinding
Returns a new instance of FreightBinding.
8 9 10 11 12 13 14 15 |
# File 'lib/freightrain/binding/freight_binding.rb', line 8 def initialize(, ) @cache = :__NOVALUE #TODO: this is necessary but really ugly - evaluate a possible replacement @widget = @property = [:property].to_s.split('.') @path = [:path].to_s.split('.') @converter = ConverterFactory.create([:converter]) || DefaultConverter.new #TODO: if in converterfactory? @force = [:force] end |
Instance Attribute Details
#data_source ⇒ Object
Returns the value of attribute data_source.
6 7 8 |
# File 'lib/freightrain/binding/freight_binding.rb', line 6 def data_source @data_source end |
Instance Method Details
#commit ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/freightrain/binding/freight_binding.rb', line 31 def commit() begin value = get(@widget, @property) set(@path, @converter.to(value), data_source) rescue Exception => ex #TODO: logger... # p "#{@widget.name} - commit" # p ex.message # p @path end end |
#update ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/freightrain/binding/freight_binding.rb', line 17 def update() begin value = get(data_source, @path) if @force || value != @cache set(@property, @converter.from(value), @widget) @cache = value end rescue Exception => ex #TODO: logger... p "#{@widget.name} - update" p ex. p @path end end |