修訂 | 131 (tree) |
---|---|
時間 | 2008-11-01 01:57:45 |
作者 | junkikuchi |
updated.
@@ -8,7 +8,7 @@ | ||
8 | 8 | class Resource < ::Widget |
9 | 9 | extend Tenarai::ClassLoader |
10 | 10 | |
11 | - property :table_name | |
11 | + property :model | |
12 | 12 | |
13 | 13 | attr_reader :content |
14 | 14 | attr_reader :model |
@@ -16,26 +16,26 @@ | ||
16 | 16 | def init(builder, service, _id=nil) |
17 | 17 | super(builder, service) |
18 | 18 | |
19 | - if property[:table_name].nil? | |
20 | - property[:table_name] = self.class.name.split('::').pop.downcase | |
19 | + if property[:model].nil? | |
20 | + property[:model] = self.class.name.split('::').pop.downcase | |
21 | 21 | end |
22 | 22 | |
23 | - @model = @service.model[property[:table_name]] | |
23 | + @model = @service.models[property[:model]] | |
24 | 24 | @content = @model.fetch(_id) |
25 | 25 | end |
26 | 26 | |
27 | - def uri(view, *param, &block) | |
27 | + def uri(view, *params, &block) | |
28 | 28 | query = Tenarai::CGI::Query.new |
29 | 29 | block.call(query) if block_given? |
30 | - build_uri(view, param, query) | |
30 | + build_uri(view, params, query) | |
31 | 31 | end |
32 | 32 | |
33 | - def widget_uri(path, query, param=[]) | |
34 | - param = [@content.id] if param.empty? && @content | |
33 | + def widget_uri(path, query, params=[]) | |
34 | + params = [@content.id] if params.empty? && @content | |
35 | 35 | if view.resource.path.include?(self) |
36 | - path << param.join(',') | |
36 | + path << params.join(',') | |
37 | 37 | else |
38 | - query[html_id] = param.join(',') | |
38 | + query[html_id] = params.join(',') | |
39 | 39 | end |
40 | 40 | end |
41 | 41 | end |