This repository was archived by the owner on Jul 31, 2019. It is now read-only.
File tree 3 files changed +21
-24
lines changed
3 files changed +21
-24
lines changed Original file line number Diff line number Diff line change 1
1
source 'https://rubygems.org'
2
2
3
- gem 'opal' , '>= 0.4.4 '
4
- gem 'opal-sprockets'
5
- gem 'opal-jquery'
6
- gem 'vienna' , :github => 'opal/vienna'
3
+ gem 'opal' , :github => 'opal/opal '
4
+ gem 'opal-sprockets' , :github => 'opal/opal-sprockets'
5
+ gem 'opal-jquery' , :github => 'opal/opal-jquery'
6
+ gem 'vienna' , :github => 'opal/vienna'
Original file line number Diff line number Diff line change 12
12
13
13
require 'models/todo'
14
14
15
- module Vienna
16
- class << self
17
- attr_accessor :application
18
- end
19
-
20
- class Application
21
- class << self
22
- def inherited ( base )
23
- Vienna . application ||= base . instance
24
- end
15
+ class Application
16
+ def run
17
+ @app_view = AppView . new
25
18
26
- def method_missing ( sym , *args )
27
- instance . __send__ ( sym , *args )
28
- end
19
+ router . update
20
+ end
29
21
30
- def instance
31
- @instance ||= self . new
22
+ def router
23
+ @router ||= Vienna ::Router . new . tap do |router |
24
+ router . route ( '/:filter' ) do |params |
25
+ apply_filter params [ :filter ]
32
26
end
33
27
end
34
28
end
35
- end
36
29
37
- class Application < Vienna ::Application
38
- def run
39
- @app_view = AppView . new
30
+ def apply_filter ( filter )
31
+ Todo . all . each { |t | t . trigger :filter , filter }
40
32
end
41
33
end
42
34
43
35
# when document is ready, lets go!
44
36
Document . ready? do
45
- Application . run
37
+ Application . new . run
46
38
end
Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ def initialize(todo)
28
28
@todo = todo
29
29
@todo . on ( :update ) { render }
30
30
@todo . on ( :destroy ) { remove }
31
+ @todo . on ( :filter ) { |filter | apply_filter filter }
32
+ end
33
+
34
+ def apply_filter ( filter )
35
+ puts "need to apply #{ filter } for #{ @todo } "
31
36
end
32
37
33
38
def clear
You can’t perform that action at this time.
0 commit comments