freightrain 0.5.11 → 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ require 'rake/testtask'
9
9
 
10
10
  spec = Gem::Specification.new do |s|
11
11
  s.name = 'freightrain'
12
- s.version = '0.5.11'
12
+ s.version = '0.5.12'
13
13
  s.add_dependency('require_all', '>= 1.1.0')
14
14
  s.add_dependency('needle', '>= 1.3.0')
15
15
  s.has_rdoc = false
@@ -3,6 +3,8 @@ module Freightrain
3
3
 
4
4
  class FreightBinding
5
5
 
6
+ attr_accessor :data_source
7
+
6
8
  def initialize(widget, options)
7
9
  @cache = :__NOVALUE
8
10
  @widget = widget
@@ -12,14 +14,6 @@ module Freightrain
12
14
  @force = options[:force]
13
15
  end
14
16
 
15
- def data_source
16
- return @data_source
17
- end
18
-
19
- def data_source=(source)
20
- @data_source = source
21
- end
22
-
23
17
  def update()
24
18
  begin
25
19
  value = get(data_source, @path)
@@ -28,9 +22,9 @@ module Freightrain
28
22
  @cache = value
29
23
  end
30
24
  rescue Exception => ex
31
- p "#{@widget.name} - update"
32
- p ex.message
33
- p @path
25
+ # p "#{@widget.name} - update"
26
+ # p ex.message
27
+ # p @path
34
28
  end
35
29
  end
36
30
 
@@ -18,17 +18,25 @@ module Freightrain
18
18
  end
19
19
  end
20
20
 
21
- def initialize()
22
- @view = Freightrain[self.class.name.sub("Model", "").to_convention_sym]
23
- get_services
24
- build_regions
25
- create_signals
26
- @view.hook_to_signals(self)
27
- services.each do |service_key|
28
- service = instance_variable_get("@#{service_key}")
21
+ def self.new(*args, &block)
22
+ viewmodel = allocate
23
+ viewmodel.bootstrap
24
+ viewmodel.send(:initialize, *args, &block)
25
+ return viewmodel
26
+ end
27
+
28
+ def bootstrap
29
+ view = Freightrain[self.class.name.sub("Model", "").to_convention_sym]
30
+ self.get_services
31
+ self.build_regions
32
+ self.create_signals
33
+ view.hook_to_signals(self)
34
+ self.services.each do |service_key|
35
+ service = self.instance_variable_get("@#{service_key}")
29
36
  service.hook_to_signals(self, service_key)
30
37
  end
31
- @view.data_source = self
38
+ view.data_source = self
39
+ @view = view
32
40
  end
33
41
 
34
42
  def show
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freightrain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.11
4
+ version: 0.5.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Dallera
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-09 00:00:00 +01:00
12
+ date: 2010-03-16 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency