• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂48 (tree)
時間2008-02-17 15:13:36
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/lib/tenarai/db/column.rb (revision 47)
+++ trunk/lib/tenarai/db/column.rb (revision 48)
@@ -16,6 +16,9 @@
1616 def accessor(row_class)
1717 row_class.module_eval <<-END
1818 def #{@name}
19+ if @row['#{@name}'].kind_of?(Tenarai::DB::Reference::Single)
20+ @row['#{@name}'] = @row['#{@name}'].fetch
21+ end
1922 @row['#{@name}']
2023 end
2124 def #{@name}=(val)
@@ -95,9 +98,10 @@
9598 class Multiple
9699 include Enumerable
97100
98- def initialize(link, row)
101+ def initialize(link, row, val)
99102 @link = link
100103 @row = row
104+ @val = val
101105 end
102106
103107 def <<(row)
@@ -105,7 +109,13 @@
105109 end
106110
107111 def each(&block)
108- @link.each(@row, &block)
112+ @link.each(@row) do |val|
113+ if val.kind_of?(Tenarai::DB::Reference::Single)
114+ block.call(val.fetch)
115+ else
116+ block.call(val)
117+ end
118+ end
109119 end
110120
111121 def size
@@ -121,10 +131,24 @@
121131 end
122132 end
123133
134+ class Single
135+ attr_reader :primary_key
136+
137+ def initialize(link, row, val)
138+ @link = link
139+ @row = row
140+ @primary_key = val
141+ end
142+
143+ def fetch
144+ @link.dst_table.fetch(@primary_key)
145+ end
146+ end
147+
124148 def initialize(name, param={})
125149 super
126150 @param[:multiple] ||= false
127- @param[:class] ||= @param[:multiple] ? Multiple : nil
151+ @param[:class] ||= @param[:multiple] ? Multiple : Single
128152 end
129153
130154 def execute(command)
--- trunk/lib/tenarai/db/relation.rb (revision 47)
+++ trunk/lib/tenarai/db/relation.rb (revision 48)
@@ -38,12 +38,12 @@
3838 end
3939 end
4040
41- def create_multiple(row, ref)
42- ref.param[:class].new(self, row)
41+ def create_multiple(ref, row, val)
42+ ref.param[:class].new(self, row, val)
4343 end
4444
45- def create_single(val)
46- val && @dst_table.fetch(val)
45+ def create_single(ref, row, val)
46+ ref.param[:class].new(self, row, val)
4747 end
4848
4949 def link(src_row, dst_row)
--- trunk/lib/tenarai/db/tree.rb (revision 47)
+++ trunk/lib/tenarai/db/tree.rb (revision 48)
@@ -56,6 +56,10 @@
5656 node.save
5757 _insert(nth, node)
5858 end
59+
60+ def empty?
61+ (@row.min + 1) == @row.max
62+ end
5963 end
6064
6165 SQLA = "UPDATE %s SET %s = %s %s ? WHERE ? <= %s ORDER BY %s %s"
--- trunk/lib/tenarai/db/engine.rb (revision 47)
+++ trunk/lib/tenarai/db/engine.rb (revision 48)
@@ -47,13 +47,13 @@
4747
4848 def multiple(ref)
4949 @handlers[ref.name] = lambda do |row, val|
50- @table.relation[ref.name].create_multiple(row, ref)
50+ @table.relation[ref.name].create_multiple(ref, row, val)
5151 end
5252 end
5353
5454 def single(ref)
5555 @handlers[ref.name] = lambda do |row, val|
56- @table.relation[ref.name].create_single(val)
56+ @table.relation[ref.name].create_single(ref, row, val)
5757 end
5858 end
5959
--- trunk/webapp/Service.rb (revision 47)
+++ trunk/webapp/Service.rb (revision 48)
@@ -71,6 +71,8 @@
7171 end
7272 end
7373
74+ widget.view.widget.load
75+
7476 widget.path.each do |r|
7577 if param.empty?
7678 if rs.key?(r.id)
--- trunk/webapp/Widget/Session.rb (revision 47)
+++ trunk/webapp/Widget/Session.rb (revision 48)
@@ -39,7 +39,7 @@
3939 end
4040
4141 def build_url(param)
42- nil
42+ 'a'
4343 end
4444
4545 def render_html(xml, builder)
--- trunk/webapp/View/Builder.rb (revision 47)
+++ trunk/webapp/View/Builder.rb (revision 48)
@@ -56,13 +56,13 @@
5656 def to_css
5757 Tenarai::CSS.new do |css|
5858 widget.render_css(css, self)
59- end.to_s(2)
59+ end.to_s(0)
6060 end
6161
6262 def to_html
6363 Tenarai::XML.new do |xml|
6464 widget.render_html(xml, self)
65- end.to_s(2)
65+ end.to_s(0)
6666 end
6767 end
6868 end
--- trunk/webapp/View.rb (revision 47)
+++ trunk/webapp/View.rb (revision 48)
@@ -31,10 +31,19 @@
3131 (['?'] * vars.size).join(', ')
3232 ]
3333
34- @link.dst_table.each(cond, *vars) do |widget|
35- block.call(widget)
34+ if block_given?
35+ @link.dst_table.each(cond, *vars) do |widget|
36+ block.call(widget)
37+ end
38+ else
39+ @link.dst_table.each(cond, *vars) do |widget|
40+ end
3641 end
3742 end
43+
44+ def load
45+ each
46+ end
3847 end
3948
4049 class << self
Show on old repository browser