apimaster 0.1.2 → 0.1.3
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/apimaster.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'apimaster'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2013-
|
5
|
-
s.summary = "ApiMaster
|
3
|
+
s.version = '0.1.3'
|
4
|
+
s.date = '2013-04-16'
|
5
|
+
s.summary = "ApiMaster"
|
6
6
|
s.description = "A simple restful api framework."
|
7
7
|
s.authors = ["Sun", "Zhang", "Li"]
|
8
8
|
s.email = 'sunxiqiu@admaster.com.cn'
|
data/lib/apimaster/mapper.rb
CHANGED
@@ -55,6 +55,7 @@ module Apimaster
|
|
55
55
|
self.send name, val
|
56
56
|
end
|
57
57
|
|
58
|
+
# to be deleted
|
58
59
|
def to_hash accessor = :all
|
59
60
|
record = {}
|
60
61
|
fields = self.class.find_attrs_in_options(:accessor, accessor)
|
@@ -69,6 +70,20 @@ module Apimaster
|
|
69
70
|
record
|
70
71
|
end
|
71
72
|
|
73
|
+
def to_api_hash accessor = :all
|
74
|
+
record = {}
|
75
|
+
fields = self.class.find_attrs_in_options(:accessor, accessor)
|
76
|
+
fields.each do |field|
|
77
|
+
if self.respond_to?(field)
|
78
|
+
val = self.send(field)
|
79
|
+
record[field] = val.respond_to?(:to_api_hash) ? val.to_api_hash(accessor) : val
|
80
|
+
else
|
81
|
+
raise "Dataset #{self.class} has no method with the name of #{field}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
record
|
85
|
+
end
|
86
|
+
|
72
87
|
def class_name
|
73
88
|
@class_name ||= self.class.to_s.split("::").last
|
74
89
|
end
|
@@ -109,6 +124,14 @@ module Apimaster
|
|
109
124
|
result
|
110
125
|
end
|
111
126
|
|
127
|
+
def to_api_hashes accessor = :all
|
128
|
+
result = []
|
129
|
+
self.each do |val|
|
130
|
+
result << val.to_api_hash(accessor)
|
131
|
+
end
|
132
|
+
result
|
133
|
+
end
|
134
|
+
|
112
135
|
end
|
113
136
|
end
|
114
137
|
end
|
data/lib/apimaster/mocks/user.rb
CHANGED
@@ -6,7 +6,8 @@ module Apimaster::Mocks
|
|
6
6
|
class User
|
7
7
|
|
8
8
|
def self.auth access_token
|
9
|
-
Apimaster::Models::User.new id: 1, email: "hello@admaster.com.cn",
|
9
|
+
Apimaster::Models::User.new id: 1, email: "hello@admaster.com.cn",
|
10
|
+
username: "hello", uuid: "1d936f8e-f7f3-11e1-975a-782bcb4b65ed"
|
10
11
|
end
|
11
12
|
|
12
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apimaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: A simple restful api framework.
|
17
17
|
email: sunxiqiu@admaster.com.cn
|
@@ -96,6 +96,6 @@ rubyforge_project:
|
|
96
96
|
rubygems_version: 1.8.25
|
97
97
|
signing_key:
|
98
98
|
specification_version: 3
|
99
|
-
summary: ApiMaster
|
99
|
+
summary: ApiMaster
|
100
100
|
test_files: []
|
101
101
|
has_rdoc:
|