ns_service_pack 0.0.14 → 0.0.15

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/README CHANGED
@@ -15,8 +15,11 @@
15
15
  * fieldmapping 和 常量管理的分离
16
16
  让使用者可以决定是否使用mapping,目前可以通过注释initializer中片段完成
17
17
  * 用模板的方法生成initializer,以便插入一些动态数据
18
- * 提供scaffold结构化方法,辅助开发
18
+ * 提供scaffold模式方法
19
+ 生成一些辅助的接口和方法
19
20
  * application_controller_module的引入还是有问题!!!
21
+ * 如何为application_controller_module中的action自动生成路由呢?
22
+ 直接生成服务端和客户端基础代码
20
23
  * index默认查询条件加入,传入条件的merge(目前已提供传入条件的精确搜索)
21
24
 
22
25
  #==NS Service Pack使用指南
@@ -62,6 +65,20 @@ end
62
65
 
63
66
 
64
67
  #==============History:
68
+ #==0.0.15
69
+ * 在mapping中支持可配置的json数据输出格式,需要:
70
+ 1. 在<mapping>.yml文件中增加一个自定义属性
71
+ :some_key_name: :get_key_value_method
72
+ 2. 在model类中增加一个该键的方法,如下:
73
+ def get_key_value_method
74
+ #give some value for the key
75
+ end
76
+ 另一种方式:
77
+ def self.get_map_value(key, value)
78
+ #ref implemented else where!
79
+ #add a when branch
80
+ end
81
+
65
82
  #==0.0.14
66
83
  * fix bug: error==>errors
67
84
 
@@ -9,7 +9,24 @@ module FieldMapping
9
9
  end
10
10
 
11
11
  def as_json(options={})
12
- self.class.buz_hashize(self.attributes)
12
+ default_attrs = self.class.buz_hashize(self.attributes)
13
+ #支持自定义方法的传入 20111118 for gao
14
+ add_virtual_buz_attributes!(default_attrs)
15
+ end
16
+
17
+ #TODO check add some notes
18
+ def add_virtual_buz_attributes!(db_buz_attrs = {})
19
+ the_mapping = self.class.mapping
20
+ delta_attrs = the_mapping.keys - db_buz_attrs.keys
21
+ delta_attrs.each do |key|
22
+ method_name = the_mapping[key]
23
+ db_buz_attrs[key] = if self.respond_to?(method_name)
24
+ self.send(method_name)
25
+ else
26
+ self.class.get_map_value(key, nil)
27
+ end
28
+ end
29
+ db_buz_attrs
13
30
  end
14
31
 
15
32
  def update_from_buz(params={})
@@ -1,4 +1,4 @@
1
1
  #coding: utf-8
2
2
  module NsServicePack
3
- VERSION = '0.0.14'
3
+ VERSION = '0.0.15'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ns_service_pack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2011-11-18 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- requirement: &75576120 !ruby/object:Gem::Requirement
18
+ requirement: &78102970 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,7 +23,7 @@ dependencies:
23
23
  version: 3.1.0
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *75576120
26
+ version_requirements: *78102970
27
27
  description: Service package for our service lier
28
28
  email: cao7113@gmail.com
29
29
  executables: []