resty-generators 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/resty/base.rb +33 -5
- data/lib/generators/resty/controller/controller_generator.rb +2 -2
- data/lib/generators/resty/model/model_generator.rb +1 -1
- data/lib/generators/resty/scaffold/scaffold_generator.rb +76 -4
- data/lib/generators/resty/setup/setup_generator.rb +141 -4
- data/lib/generators/resty/setup/templates/ActivityFactory.java +12 -0
- data/lib/generators/resty/setup/templates/ActivityPlace.java +25 -0
- data/lib/generators/resty/setup/templates/ActivityPlaceActivityMapper.java +30 -0
- data/lib/generators/resty/setup/templates/BreadCrumbsPanel.java +80 -0
- data/lib/generators/resty/setup/templates/EntryPoint.java +75 -4
- data/lib/generators/resty/setup/templates/GinModule.java +40 -0
- data/lib/generators/resty/setup/templates/LoginActivity.java +59 -0
- data/lib/generators/resty/setup/templates/LoginPlace.java +20 -0
- data/lib/generators/resty/setup/templates/LoginView.ui.xml +18 -0
- data/lib/generators/resty/setup/templates/LoginViewImpl.java +21 -0
- data/lib/generators/resty/setup/templates/Mavenfile +7 -4
- data/lib/generators/resty/setup/templates/PlaceHistoryMapper.java +8 -0
- data/lib/generators/resty/setup/templates/RestfulPlace.java +24 -0
- data/lib/generators/resty/setup/templates/SessionActivityPlaceActivityMapper.java +71 -0
- data/lib/generators/resty/setup/templates/SessionRestService.java +23 -0
- data/lib/generators/resty/setup/templates/User.java +8 -0
- data/lib/generators/resty/setup/templates/authentication.rb +3 -0
- data/lib/generators/resty/setup/templates/empty.css +17 -0
- data/lib/generators/resty/setup/templates/gitignore +3 -0
- data/lib/generators/resty/setup/templates/group.rb +14 -0
- data/lib/generators/resty/setup/templates/gwt.css +17 -0
- data/lib/generators/resty/setup/templates/module.gwt.xml +9 -2
- data/lib/generators/resty/setup/templates/page.html +1 -1
- data/lib/generators/resty/setup/templates/session.rb +45 -0
- data/lib/generators/resty/setup/templates/sessions_controller.rb +29 -0
- data/lib/generators/resty/setup/templates/user.rb +28 -0
- data/lib/generators/resty/setup/templates/web.xml +50 -0
- data/lib/generators/resty/templates/Activity.java +140 -0
- data/lib/generators/resty/templates/ColumnDefinitionsImpl.java +24 -0
- data/lib/generators/resty/templates/Model.java +13 -7
- data/lib/generators/resty/templates/Place.java +27 -0
- data/lib/generators/resty/templates/PlaceTokenizer.java +25 -0
- data/lib/generators/resty/templates/{Controller.java → RestService.java} +16 -12
- data/lib/generators/resty/templates/View.java +35 -0
- data/lib/generators/resty/templates/View.ui.xml +47 -0
- data/lib/generators/resty/templates/ViewImpl.java +196 -0
- data/lib/resty-generators.rb +1 -0
- data/lib/resty/child_path.rb +17 -4
- data/lib/resty/resty_railtie.rb +4 -5
- metadata +70 -60
@@ -0,0 +1,25 @@
|
|
1
|
+
package <%= places_package %>;
|
2
|
+
|
3
|
+
import com.google.gwt.place.shared.PlaceTokenizer;
|
4
|
+
import com.google.gwt.place.shared.Prefix;
|
5
|
+
|
6
|
+
import <%= gwt_rails_package %>.RestfulPlaceTokenizer;
|
7
|
+
|
8
|
+
@Prefix("<% if options[:singleton] -%><%= singular_table_name %><% else -%><%= table_name %><% end -%>")
|
9
|
+
public class <%= class_name %>PlaceTokenizer extends RestfulPlaceTokenizer<<%= class_name %>Place>
|
10
|
+
implements PlaceTokenizer<<%= class_name %>Place> {
|
11
|
+
|
12
|
+
public <%= class_name %>Place getPlace(String token) {
|
13
|
+
<% if options[:singleton] -%>
|
14
|
+
return new <%= class_name %>Place(toSingletonToken(token).action);
|
15
|
+
<% else -%>
|
16
|
+
Token t = toToken(token);
|
17
|
+
if(t.identifier == null){
|
18
|
+
return new <%= class_name %>Place(t.action);
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
return new <%= class_name %>Place(t.identifier, t.action);
|
22
|
+
}
|
23
|
+
<% end -%>
|
24
|
+
}
|
25
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
|
-
package <%=
|
1
|
+
package <%= restservices_package %>;
|
2
2
|
|
3
|
+
import <%= gwt_rails_package %>.RestfulDispatcherSingleton;
|
3
4
|
<% if action_map.values.member? :get_all -%>
|
4
5
|
import java.util.List;
|
5
6
|
<% end -%>
|
@@ -7,43 +8,46 @@ import java.util.List;
|
|
7
8
|
import javax.ws.rs.*;
|
8
9
|
|
9
10
|
import org.fusesource.restygwt.client.*;
|
11
|
+
import org.fusesource.restygwt.client.dispatcher.DefaultDispatcher;
|
10
12
|
|
11
13
|
<% if name -%>
|
12
|
-
import <%=
|
14
|
+
import <%= models_package %>.*;
|
13
15
|
<% end -%>
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
<% if options[:singleton] -%>@Path("/<%= singular_table_name %>")<% end %>
|
18
|
+
@Options(dispatcher = RestfulDispatcherSingleton.class)
|
19
|
+
public interface <%= controller_class_name %>RestService extends RestService {
|
17
20
|
|
18
21
|
<% actions.each do |action|
|
19
22
|
case action_map[action]
|
20
23
|
when :get_all -%>
|
21
|
-
@GET @Path("/<%= table_name
|
24
|
+
@GET @Path("/<%= table_name %>")
|
25
|
+
@Options(dispatcher = DefaultDispatcher.class)
|
22
26
|
void <%= action %>(MethodCallback<List<<%= class_name %>>> callback);
|
23
27
|
|
24
|
-
// @GET @Path("/<%= table_name
|
28
|
+
// @GET @Path("/<%= table_name %>")
|
25
29
|
// void <%= action %>(MethodCallback<List<<%= class_name %>>> callback, @QueryParam("limit") int limit, @QueryParam("offset") int offset);
|
26
30
|
//
|
27
31
|
<% when :get_single -%>
|
28
|
-
@GET<% unless options[:singleton] -%> @Path("/<%= table_name %>/{id}
|
32
|
+
@GET<% unless options[:singleton] -%> @Path("/<%= table_name %>/{id}")<% end %>
|
29
33
|
void <%= action %>(<% unless options[:singleton] -%>@PathParam("id") int id, <% end -%>MethodCallback<<%= class_name %>> callback);
|
30
34
|
|
31
35
|
<% when :post -%>
|
32
|
-
@POST @Path("/<%= table_name
|
36
|
+
@POST @Path("/<%= table_name %>")
|
33
37
|
void <%= action %>(<%= class_name %> value, MethodCallback<<%= class_name %>> callback);
|
34
38
|
|
35
39
|
<% when :put -%>
|
36
|
-
@PUT<% unless options[:singleton] -%> @Path("/<%= table_name %>/{id}
|
40
|
+
@PUT<% unless options[:singleton] -%> @Path("/<%= table_name %>/{id}")<% end %>
|
37
41
|
void <%= action %>(<% unless options[:singleton] -%>@PathParam("id") @Attribute("id") <% end -%><%= class_name %> value, MethodCallback<<%= class_name %>> callback);
|
38
42
|
|
39
43
|
<% when :delete -%>
|
40
|
-
@DELETE @Path("/<%= table_name %>/{id}
|
44
|
+
@DELETE @Path("/<%= table_name %>/{id}")
|
41
45
|
void <%= action %>(@PathParam("id") @Attribute("id") <%= class_name %> value, MethodCallback<Void> callback);
|
42
46
|
|
43
47
|
<% else -%>
|
44
|
-
@GET @Path("/<%= table_name %>/<%= action
|
48
|
+
@GET @Path("/<%= table_name %>/<%= action %>")
|
45
49
|
void <%= action %>(MethodCallback<Void> callback);
|
46
50
|
|
47
51
|
<% end
|
48
52
|
end -%>
|
49
|
-
}
|
53
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
package <%= views_package %>;
|
2
|
+
|
3
|
+
import java.util.List;
|
4
|
+
|
5
|
+
import <%= models_package %>.<%= class_name %>;
|
6
|
+
|
7
|
+
import com.google.gwt.place.shared.Place;
|
8
|
+
import com.google.gwt.user.client.ui.IsWidget;
|
9
|
+
import com.google.inject.ImplementedBy;
|
10
|
+
|
11
|
+
import <%= gwt_rails_package %>.RestfulAction;
|
12
|
+
|
13
|
+
@ImplementedBy(<%= class_name %>ViewImpl.class)
|
14
|
+
public interface <%= class_name %>View extends IsWidget {
|
15
|
+
|
16
|
+
public interface Presenter {
|
17
|
+
<% unless options[:singleton] -%>
|
18
|
+
void create();
|
19
|
+
<% end -%>
|
20
|
+
void save();
|
21
|
+
<% unless options[:singleton] -%>
|
22
|
+
void delete();
|
23
|
+
<% end -%>
|
24
|
+
void goTo(Place place);
|
25
|
+
}
|
26
|
+
void setPresenter(Presenter presenter);
|
27
|
+
|
28
|
+
void reset(<%= class_name %> model);
|
29
|
+
|
30
|
+
void reset(RestfulAction action);
|
31
|
+
|
32
|
+
void setEnabled(boolean enabled);
|
33
|
+
|
34
|
+
<%= class_name %> retrieve<%= class_name %>();
|
35
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
2
|
+
<ui:UiBinder
|
3
|
+
xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
4
|
+
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
5
|
+
|
6
|
+
<ui:style>
|
7
|
+
.buttons {}
|
8
|
+
.signatur { float: left; }
|
9
|
+
.signatur * { display: inline; margin-right: 1em; font-size: 0.8em;}
|
10
|
+
.fields { clear: both;}
|
11
|
+
.field { }
|
12
|
+
</ui:style>
|
13
|
+
|
14
|
+
<g:FlowPanel>
|
15
|
+
<g:FlowPanel styleName="{style.buttons}">
|
16
|
+
<% unless options[:singleton] -%>
|
17
|
+
<g:Button ui:field="newButton">New</g:Button>
|
18
|
+
<g:Button ui:field="createButton">Create</g:Button>
|
19
|
+
<% end -%>
|
20
|
+
<g:Button ui:field="editButton">Edit</g:Button>
|
21
|
+
<g:Button ui:field="saveButton">Save</g:Button>
|
22
|
+
<% unless options[:singleton] -%>
|
23
|
+
<g:Button ui:field="deleteButton">Delete</g:Button>
|
24
|
+
<% end -%>
|
25
|
+
</g:FlowPanel>
|
26
|
+
<g:FlowPanel styleName="{style.signatur}">
|
27
|
+
<% unless options[:singleton] -%>
|
28
|
+
<g:Label ui:field="id" />
|
29
|
+
<% end -%>
|
30
|
+
<% if options[:timestamps] %>
|
31
|
+
<g:Label ui:field="createdAt" />
|
32
|
+
<g:Label ui:field="updatedAt" />
|
33
|
+
<% end -%>
|
34
|
+
</g:FlowPanel>
|
35
|
+
<g:FlowPanel styleName="{style.fields}">
|
36
|
+
<% for attribute in attributes -%>
|
37
|
+
<% if attribute.type != :has_one && attribute.type != :has_many -%>
|
38
|
+
<% name = attribute.name.classify.sub(/^(.)/){ $1.downcase } -%>
|
39
|
+
<g:FlowPanel styleName="{style.field}">
|
40
|
+
<g:HTML><label name="<%= name %>"><%= name.humanize %></label></g:HTML>
|
41
|
+
<g:TextBox ui:field="<%= name %>" name="<%= name %>"/>
|
42
|
+
</g:FlowPanel>
|
43
|
+
<% end -%>
|
44
|
+
<% end -%>
|
45
|
+
</g:FlowPanel>
|
46
|
+
</g:FlowPanel>
|
47
|
+
</ui:UiBinder>
|
@@ -0,0 +1,196 @@
|
|
1
|
+
package <%= views_package %>;
|
2
|
+
|
3
|
+
<% if options[:timestamps] %>
|
4
|
+
import java.util.Date;
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
import <%= gwt_rails_package %>.RestfulAction;
|
8
|
+
import <%= gwt_rails_package %>.RestfulActionEnum;
|
9
|
+
|
10
|
+
import <%= models_package %>.<%= class_name %>;
|
11
|
+
import <%= places_package %>.<%= class_name %>Place;
|
12
|
+
|
13
|
+
import com.google.gwt.core.client.GWT;
|
14
|
+
import com.google.gwt.event.dom.client.ClickEvent;
|
15
|
+
<% if options[:timestamps] %>
|
16
|
+
import com.google.gwt.i18n.client.DateTimeFormat;
|
17
|
+
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
18
|
+
<% end -%>
|
19
|
+
import com.google.gwt.uibinder.client.UiBinder;
|
20
|
+
import com.google.gwt.uibinder.client.UiField;
|
21
|
+
import com.google.gwt.uibinder.client.UiHandler;
|
22
|
+
import com.google.gwt.uibinder.client.UiTemplate;
|
23
|
+
import com.google.gwt.user.client.ui.*;
|
24
|
+
import com.google.inject.Singleton;
|
25
|
+
|
26
|
+
@Singleton
|
27
|
+
public class <%= class_name %>ViewImpl extends Composite
|
28
|
+
implements <%= class_name %>View {
|
29
|
+
|
30
|
+
@UiTemplate("<%= class_name %>View.ui.xml")
|
31
|
+
interface <%= class_name %>ViewUiBinder extends UiBinder<Widget, <%= class_name %>ViewImpl> {}
|
32
|
+
|
33
|
+
private static <%= class_name %>ViewUiBinder uiBinder = GWT.create(<%= class_name %>ViewUiBinder.class);
|
34
|
+
|
35
|
+
<% unless options[:singleton] -%>
|
36
|
+
@UiField
|
37
|
+
Button newButton;
|
38
|
+
|
39
|
+
@UiField
|
40
|
+
Button createButton;
|
41
|
+
<% end -%>
|
42
|
+
@UiField
|
43
|
+
Button editButton;
|
44
|
+
|
45
|
+
@UiField
|
46
|
+
Button saveButton;
|
47
|
+
<% unless options[:singleton] -%>
|
48
|
+
@UiField
|
49
|
+
Button deleteButton;
|
50
|
+
|
51
|
+
@UiField
|
52
|
+
Label id;
|
53
|
+
|
54
|
+
<% end -%>
|
55
|
+
<% if options[:timestamps] %>
|
56
|
+
@UiField
|
57
|
+
Label createdAt;
|
58
|
+
|
59
|
+
@UiField
|
60
|
+
Label updatedAt;
|
61
|
+
|
62
|
+
<% end -%>
|
63
|
+
<% for attribute in attributes -%>
|
64
|
+
<% if attribute.type == :has_one -%>
|
65
|
+
// TODO <%= attribute.name.classify %> <%= attribute.name %>;
|
66
|
+
<% elsif attribute.type == :has_many -%>
|
67
|
+
// TODO public java.util.List<<%= attribute.name.classify %>> <%= attribute.name %>;
|
68
|
+
<% else -%>
|
69
|
+
@UiField
|
70
|
+
TextBox <%= attribute.name.classify.sub(/^(.)/){ $1.downcase } %>;
|
71
|
+
<% end -%>
|
72
|
+
|
73
|
+
<% end -%>
|
74
|
+
|
75
|
+
private Presenter presenter;
|
76
|
+
|
77
|
+
<% unless options[:singleton] -%>
|
78
|
+
private int idCache;
|
79
|
+
|
80
|
+
<% end -%>
|
81
|
+
<% if options[:timestamps] %>
|
82
|
+
private Date createdAtCache;
|
83
|
+
private Date updatedAtCache;
|
84
|
+
|
85
|
+
<% end -%>
|
86
|
+
public <%= class_name %>ViewImpl() {
|
87
|
+
initWidget(uiBinder.createAndBindUi(this));
|
88
|
+
}
|
89
|
+
<% unless options[:singleton] -%>
|
90
|
+
@UiHandler("newButton")
|
91
|
+
void onClickNew(ClickEvent e) {
|
92
|
+
presenter.goTo(new <%= class_name %>Place(RestfulActionEnum.NEW));
|
93
|
+
}
|
94
|
+
|
95
|
+
@UiHandler("createButton")
|
96
|
+
void onClickCreate(ClickEvent e) {
|
97
|
+
presenter.create();
|
98
|
+
}
|
99
|
+
<% end -%>
|
100
|
+
@UiHandler("editButton")
|
101
|
+
void onClickEdit(ClickEvent e) {
|
102
|
+
presenter.goTo(new <%= class_name %>Place(<% unless options[:singleton] -%>idCache, <% end -%>RestfulActionEnum.EDIT));
|
103
|
+
}
|
104
|
+
|
105
|
+
@UiHandler("saveButton")
|
106
|
+
void onClickSave(ClickEvent e) {
|
107
|
+
presenter.save();
|
108
|
+
}
|
109
|
+
<% unless options[:singleton] -%>
|
110
|
+
@UiHandler("deleteButton")
|
111
|
+
void onClickDelete(ClickEvent e) {
|
112
|
+
presenter.delete();
|
113
|
+
}
|
114
|
+
<% end -%>
|
115
|
+
public void setPresenter(Presenter presenter) {
|
116
|
+
this.presenter = presenter;
|
117
|
+
}
|
118
|
+
|
119
|
+
public void reset(<%= class_name %> model) {
|
120
|
+
<% if options[:singleton] -%>
|
121
|
+
//TODO singleton support
|
122
|
+
<% else -%>
|
123
|
+
if(model.id > 0){
|
124
|
+
id.setText("id: " + model.id);
|
125
|
+
<% if options[:timestamps] %>
|
126
|
+
createdAt.setText("created at: "
|
127
|
+
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM).format(model.created_at));
|
128
|
+
updatedAt.setText("updated at: "
|
129
|
+
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM).format(model.updated_at));
|
130
|
+
<% end -%>
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
id.setText(null);
|
134
|
+
<% if options[:timestamps] %>
|
135
|
+
createdAt.setText(null);
|
136
|
+
updatedAt.setText(null);
|
137
|
+
<% end -%>
|
138
|
+
}
|
139
|
+
this.idCache = model.id;
|
140
|
+
<% if options[:timestamps] %>
|
141
|
+
this.createdAtCache = model.created_at;
|
142
|
+
this.updatedAtCache = model.updated_at;
|
143
|
+
<% end -%>
|
144
|
+
<% end -%>
|
145
|
+
<% for attribute in attributes -%>
|
146
|
+
<% if attribute.type != :has_one && attribute.type != :has_many -%>
|
147
|
+
<% name = attribute.name.classify.sub(/^(.)/){ $1.downcase } -%>
|
148
|
+
<% field_name = attribute.name.classify.underscore.sub(/^(.)/){ $1.downcase } -%>
|
149
|
+
<%= name %>.setText(model.<%= field_name %><% if type_conversion_map[attribute.type] -%> + ""<% end -%>);
|
150
|
+
<% end -%>
|
151
|
+
<% end -%>
|
152
|
+
}
|
153
|
+
|
154
|
+
public void reset(RestfulAction action) {
|
155
|
+
GWT.log(action.name() + " <%= class_name %>"<% unless options[:singleton] -%> + (idCache > 0 ? "(" + id + ")" : "")<% end -%>);
|
156
|
+
<% unless options[:singleton] -%>
|
157
|
+
newButton.setVisible(!action.name().equals(RestfulActionEnum.NEW.name()));
|
158
|
+
createButton.setVisible(action.name().equals(RestfulActionEnum.NEW.name()));
|
159
|
+
<% end -%>
|
160
|
+
editButton.setVisible(action.name().equals(RestfulActionEnum.SHOW.name()));
|
161
|
+
saveButton.setVisible(action.name().equals(RestfulActionEnum.EDIT.name()));
|
162
|
+
<% unless options[:singleton] -%>
|
163
|
+
deleteButton.setVisible(!action.name().equals(RestfulActionEnum.NEW.name()));
|
164
|
+
<% end -%>
|
165
|
+
setEnabled(!action.viewOnly());
|
166
|
+
}
|
167
|
+
|
168
|
+
public <%= class_name %> retrieve<%= class_name %>() {
|
169
|
+
<%= class_name %> model = new <%= class_name %>();
|
170
|
+
<% unless options[:singleton] -%>
|
171
|
+
model.id = idCache;
|
172
|
+
<% end -%>
|
173
|
+
<% if options[:timestamps] %>
|
174
|
+
model.created_at = createdAtCache;
|
175
|
+
model.updated_at = updatedAtCache;
|
176
|
+
<% end -%>
|
177
|
+
|
178
|
+
<% for attribute in attributes -%>
|
179
|
+
<% if attribute.type != :has_one && attribute.type != :has_many -%>
|
180
|
+
<% name = attribute.name.classify.sub(/^(.)/){ $1.downcase } -%>
|
181
|
+
model.<%= attribute.name.classify.underscore.sub(/^(.)/){ $1.downcase } %> = <% if (conv = type_conversion_map[attribute.type]).nil? -%><%= name %>.getText()<% else -%><%= conv %>(<%= name %>.getText())<% end -%>;
|
182
|
+
<% end -%>
|
183
|
+
|
184
|
+
<% end -%>
|
185
|
+
return model;
|
186
|
+
}
|
187
|
+
|
188
|
+
public void setEnabled(boolean enabled) {
|
189
|
+
<% for attribute in attributes -%>
|
190
|
+
<% if attribute.type != :has_one && attribute.type != :has_many -%>
|
191
|
+
<% name = attribute.name.classify.sub(/^(.)/){ $1.downcase } -%>
|
192
|
+
<%= name %>.setEnabled(enabled);
|
193
|
+
<% end -%>
|
194
|
+
<% end -%>
|
195
|
+
}
|
196
|
+
}
|
data/lib/resty-generators.rb
CHANGED
data/lib/resty/child_path.rb
CHANGED
@@ -6,13 +6,26 @@ module Resty
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(env)
|
9
|
+
is_json = (env['CONTENT_TYPE'] || env['HTTP_ACCEPT']) =~ /^application\/json/
|
10
|
+
is_child = false
|
9
11
|
['REQUEST_PATH','PATH_INFO','REQUEST_URI','SCRIPT_NAME'].each do |key|
|
10
|
-
if(env[key] =~ /\.json([?].*)?$/)
|
11
|
-
|
12
|
+
if(is_json || env[key] =~ /\.json([?].*)?$/)
|
13
|
+
is_json = true
|
14
|
+
value = env[key]
|
15
|
+
if value
|
16
|
+
is_child = is_child || value =~ /^\/#{@rootpath}\//
|
17
|
+
value.gsub!(/^\/#{@rootpath}\//, "/")
|
18
|
+
end
|
12
19
|
end
|
13
20
|
end
|
14
|
-
@app.call(env)
|
21
|
+
status, headers, response = @app.call(env)
|
22
|
+
if is_child && headers['Location']
|
23
|
+
uri = URI(headers['Location'])
|
24
|
+
uri.path.gsub!(/^\//, "/#{@rootpath}/")
|
25
|
+
headers['Location'] = uri.to_s
|
26
|
+
end
|
27
|
+
headers['Content-Type'] = 'application/json' if is_json
|
28
|
+
[status, headers, response]
|
15
29
|
end
|
16
|
-
|
17
30
|
end
|
18
31
|
end
|
data/lib/resty/resty_railtie.rb
CHANGED
@@ -10,7 +10,6 @@ module Resty
|
|
10
10
|
Rails::Generators::ControllerGenerator.hook_for :resty, :type => :boolean, :default => true do |controller|
|
11
11
|
invoke controller, [ class_name, actions ]
|
12
12
|
end
|
13
|
-
#Erb::Generators::ScaffoldGenerator.source_paths.insert(0, File.expand_path('../../generators/ixtlan/templates', __FILE__))
|
14
13
|
end
|
15
14
|
|
16
15
|
config.after_initialize do
|
@@ -21,22 +20,22 @@ module Resty
|
|
21
20
|
# get the time/date format right ;-) and match it with resty
|
22
21
|
class DateTime
|
23
22
|
def as_json(options = nil)
|
24
|
-
strftime('%Y-%m-%dT%H:%M:%S.%
|
23
|
+
strftime('%Y-%m-%dT%H:%M:%S.%N%z')
|
25
24
|
end
|
26
25
|
end
|
27
26
|
class ActiveSupport::TimeWithZone
|
28
27
|
def as_json(options = nil)
|
29
|
-
strftime('%Y-%m-%dT%H:%M:%S.%
|
28
|
+
strftime('%Y-%m-%dT%H:%M:%S.%N%z')
|
30
29
|
end
|
31
30
|
end
|
32
31
|
class Date
|
33
32
|
def as_json(options = nil)
|
34
|
-
strftime('%Y-%m-%dT%H:%M:%S.%
|
33
|
+
strftime('%Y-%m-%dT%H:%M:%S.%N%z')
|
35
34
|
end
|
36
35
|
end
|
37
36
|
class Time
|
38
37
|
def as_json(options = nil)
|
39
|
-
strftime('%Y-%m-%dT%H:%M:%S.%
|
38
|
+
strftime('%Y-%m-%dT%H:%M:%S.%N%z')
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|