nyara 0.1.pre.0 → 0.1.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nyara +2 -14
  3. data/changes +3 -0
  4. data/example/factorial.rb +19 -0
  5. data/example/hello.rb +5 -0
  6. data/example/project.rb +11 -0
  7. data/example/stream.rb +14 -0
  8. data/ext/extconf.rb +19 -0
  9. data/ext/hashes.c +160 -57
  10. data/ext/inc/ary_intern.h +36 -0
  11. data/ext/route.cc +2 -1
  12. data/ext/url_encoded.c +1 -0
  13. data/lib/nyara.rb +1 -0
  14. data/lib/nyara/command.rb +60 -79
  15. data/lib/nyara/config.rb +19 -1
  16. data/lib/nyara/controller.rb +64 -7
  17. data/lib/nyara/hashes/config_hash.rb +3 -20
  18. data/lib/nyara/hashes/header_hash.rb +2 -2
  19. data/lib/nyara/hashes/param_hash.rb +1 -0
  20. data/lib/nyara/nyara.rb +45 -37
  21. data/lib/nyara/part.rb +2 -2
  22. data/lib/nyara/reload.rb +63 -64
  23. data/lib/nyara/route.rb +7 -6
  24. data/lib/nyara/session.rb +4 -0
  25. data/lib/nyara/templates/{Gemfile → Gemfile.tt} +4 -0
  26. data/lib/nyara/templates/Linnerfile +28 -0
  27. data/lib/nyara/templates/Rakefile +16 -2
  28. data/lib/nyara/templates/app/assets/files/favicon.ico +1 -0
  29. data/lib/nyara/templates/app/assets/files/robots.txt +5 -0
  30. data/lib/nyara/templates/app/assets/scripts/app.coffee +4 -0
  31. data/lib/nyara/templates/app/assets/scripts/module-example.coffee +4 -0
  32. data/lib/nyara/templates/app/assets/styles/app.scss +2 -0
  33. data/lib/nyara/templates/app/controllers/application_controller.rb +8 -0
  34. data/lib/nyara/templates/app/views/layouts/application.erb.tt +12 -0
  35. data/lib/nyara/templates/config/application.rb +4 -0
  36. data/lib/nyara/templates/config/{database.yml → database.yml.tt} +3 -3
  37. data/lib/nyara/templates/config/production.rb +2 -0
  38. data/lib/nyara/view.rb +6 -2
  39. data/nyara.gemspec +3 -1
  40. data/rakefile +7 -26
  41. data/spec/apps/reload.rb +35 -0
  42. data/spec/command_spec.rb +24 -10
  43. data/spec/config_spec.rb +19 -8
  44. data/spec/controller_spec.rb +14 -0
  45. data/spec/evented_io_spec.rb +3 -1
  46. data/spec/ext_route_spec.rb +25 -3
  47. data/spec/hashes_spec.rb +45 -21
  48. data/spec/integration_spec.rb +28 -2
  49. data/spec/path_helper_spec.rb +7 -0
  50. data/spec/performance_spec.rb +1 -1
  51. data/spec/public/test.css +1 -0
  52. data/{lib/nyara/templates/public/robot.txt → spec/public/test.jpg} +0 -0
  53. data/spec/public/test.js +1 -0
  54. data/spec/reload_spec.rb +50 -0
  55. data/spec/route_spec.rb +4 -4
  56. data/spec/spec_helper.rb +15 -9
  57. data/spec/url_encoded_spec.rb +5 -0
  58. data/spec/view_spec.rb +7 -0
  59. data/spec/views/_partial.slim +1 -1
  60. data/tools/bug.rb +53 -0
  61. data/tools/hello.rb +49 -0
  62. data/tools/memcheck.rb +33 -0
  63. metadata +73 -41
  64. data/ext/inc/status_codes.inc +0 -64
  65. data/lib/nyara/templates/app/views/layouts/application.erb +0 -12
  66. data/lib/nyara/templates/public/css/app.css +0 -1
  67. data/lib/nyara/templates/public/js/app.js +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8488241a4b245171cf578a271e64cde4bcb5e992
4
- data.tar.gz: 157848c9c7f726ebc67fbb9f63fb823274ed2312
3
+ metadata.gz: e8806d56e981db23403ba6662c31af80629c2afd
4
+ data.tar.gz: 98d333128c7785a3b32e49ffbf4c7cc16f570c16
5
5
  SHA512:
6
- metadata.gz: dfc38bc4139cdae9178f69db59bffc2fa46867bb40864e8c1df13f80ca9a95707795ed2a48c9a4b3cc2c248726571cfbff062d515c2bf113095d5deafc89003f
7
- data.tar.gz: 9d40524878b0ca0ba9d1606c9ad4f4336dc51ac042946fc53b04285dfbc8625248629522d1497cd36a1e9d95d4c4e00b8646ce0d84d8e936264bf7ca53a5eecd
6
+ metadata.gz: 79b6568857f0ef7fb6e5bd3d2286f68777554536e4223e592e48cface08b0754c3c4b725a7b52838617f48d1ee969c1aa412e3a3eae0710d5f1ef0d488ed3b7c
7
+ data.tar.gz: 5790f2a3e825c6eec82c0befab9a9e596894e71996ae922c63ca3bac48a5e1c0caf818cfd5f2a0cbc7347f6eff934ad36139e2ca8d4fd3b4687cd829308977a3
data/bin/nyara CHANGED
@@ -1,17 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative "../lib/nyara/nyara"
3
+ require_relative "../lib/nyara/command"
3
4
 
4
- args = ARGV.dup
5
- task_name = args.shift || 'help'
6
-
7
-
8
- case task_name
9
- when 'help', '-h'
10
- Nyara::Command.help
11
- when '-v'
12
- Nyara::Command.version
13
- when 'new'
14
- Nyara::Command.new_project(*args)
15
- when 's','server'
16
- Nyara::Command.run_server(*args)
17
- end
5
+ Nyara::Command.start
data/changes CHANGED
@@ -1,3 +1,6 @@
1
+ 2013-08-17 integrate with linner
2
+ 2013-08-16 use thor for `nyara` commands
3
+ 2013-08-15 (developers) migrated to git subtree, you don't need to hand-update submodules anymore
1
4
  2013-07-18 add automatic reloader for development mode
2
5
  2013-07-13 add bin script `nyara`
3
6
  2013-07-10 add before filter
@@ -0,0 +1,19 @@
1
+ require 'nyara'
2
+
3
+ get '/factorial(%u)' do |n|
4
+ redirect_to '#product', 1, n
5
+ end
6
+
7
+ meta '#product'
8
+ get '/%u*factorial(%u)' do |product, n|
9
+ if n == 0
10
+ redirect_to '#result', product
11
+ else
12
+ redirect_to '#product', product * n, n - 1
13
+ end
14
+ end
15
+
16
+ meta '#result'
17
+ get '/%u' do |result|
18
+ send_string result
19
+ end
data/example/hello.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "nyara"
2
+
3
+ get '/' do
4
+ send_string 'hello world'
5
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "../lib/nyara"
2
+
3
+ configure do
4
+ set :root, __dir__
5
+ set :public, 'public'
6
+ set :views, 'views'
7
+ end
8
+
9
+ get '/' do
10
+ send_string 'hello'
11
+ end
data/example/stream.rb ADDED
@@ -0,0 +1,14 @@
1
+ require_relative "../lib/nyara"
2
+ require "pry"
3
+
4
+ configure do
5
+ set :root, __dir__
6
+ end
7
+
8
+ get '/' do
9
+ view = stream 'index'
10
+ 4.times do
11
+ sleep 1
12
+ view.resume
13
+ end
14
+ end
data/ext/extconf.rb CHANGED
@@ -1,5 +1,23 @@
1
+ Dir.chdir __dir__
1
2
  require "mkmf"
2
3
 
4
+ def generate_version_file
5
+ version_file = 'inc/version.inc'
6
+ puts "generating: #{version_file}"
7
+ lines = File.readlines('../nyara.gemspec')
8
+ version = nil
9
+ lines.each do |line|
10
+ if line =~ /s\.version =/
11
+ version = line[/\d+(\.\d+)*(\.pre\.\d+)?/]
12
+ break
13
+ end
14
+ end
15
+ abort 'version not found' unless version
16
+ File.open version_file, 'w' do |f|
17
+ f.puts %Q{#define NYARA_VERSION "#{version}"}
18
+ end
19
+ end
20
+
3
21
  def tweak_include
4
22
  dir = File.dirname __FILE__
5
23
  multipart_dir = File.join dir, "multipart-parser-c"
@@ -35,4 +53,5 @@ have_func('rb_ary_new_capa', 'ruby.h')
35
53
 
36
54
  tweak_include
37
55
  tweak_cflags
56
+ generate_version_file
38
57
  create_makefile 'nyara'
data/ext/hashes.c CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  #include "nyara.h"
4
4
  #include <ruby/st.h>
5
+ #include <assert.h>
5
6
  #include "inc/str_intern.h"
7
+ #include "inc/ary_intern.h"
6
8
  #include <ctype.h>
7
9
 
8
10
  VALUE nyara_param_hash_class;
@@ -42,29 +44,26 @@ static VALUE param_hash_aset(VALUE self, VALUE key, VALUE value) {
42
44
  return rb_hash_aset(self, key, value);
43
45
  }
44
46
 
45
- // prereq: name should be already url decoded <br>
46
- // "a[b][][c]" ==> ["a", "b", "", "c"]
47
- static VALUE param_hash_split_name(VALUE _, VALUE name) {
48
- Check_Type(name, T_STRING);
47
+ // replace content of keys with split name
48
+ // existing prefices are not replaced for minimal allocation
49
+ static VALUE _split_name(volatile VALUE name) {
49
50
  long len = RSTRING_LEN(name);
50
51
  if (len == 0) {
51
52
  rb_raise(rb_eArgError, "name should not be empty");
52
53
  }
53
54
  char* s = RSTRING_PTR(name);
54
55
 
55
- // NOTE it's OK to compare utf-8 string with ascii chars, because utf-8 code units are either:
56
- // - byte with 0 in highest nibble, which is ascii char
57
- // - bytes with 1 in highest nibble, which can not be eql to any ascii char
58
-
59
56
  volatile VALUE keys = rb_ary_new();
57
+ # define INSERT(s, len) \
58
+ rb_ary_push(keys, rb_enc_str_new(s, len, u8_encoding))
59
+
60
60
  long i;
61
61
  for (i = 0; i < len; i++) {
62
62
  if (s[i] == '[') {
63
63
  if (i == 0) {
64
64
  rb_raise(rb_eArgError, "bad name (starts with '[')");
65
65
  }
66
- volatile VALUE key = rb_enc_str_new(s, i, u8_encoding);
67
- rb_ary_push(keys, key);
66
+ INSERT(s, i);
68
67
  i++;
69
68
  break;
70
69
  } else if (s[i] == ']') {
@@ -80,8 +79,7 @@ static VALUE param_hash_split_name(VALUE _, VALUE name) {
80
79
  for (long j = last_j; j < len; j++) {
81
80
  if (s[j] == ']') {
82
81
  if (j == len - 1 || s[j + 1] == '[') {
83
- volatile VALUE key = rb_enc_str_new(s + last_j, j - last_j, u8_encoding);
84
- rb_ary_push(keys, key);
82
+ INSERT(s + last_j, j - last_j);
85
83
  last_j = j + 2; // fine for last round
86
84
  j++;
87
85
  } else {
@@ -95,70 +93,155 @@ static VALUE param_hash_split_name(VALUE _, VALUE name) {
95
93
  // single key
96
94
  rb_ary_push(keys, name);
97
95
  }
96
+ # undef INSERT
98
97
  return keys;
99
98
  }
100
99
 
101
- // assume keys = [a, b, c] ==> self[a][b][c] = value
102
- // blank keys will be translated as array keys.
103
- // created hashes has the same class with output
104
- // todo make 2 versions, one for public use
105
- static VALUE param_hash_nested_aset(VALUE output, volatile VALUE keys, VALUE value) {
100
+ // prereq: name should be already url decoded <br>
101
+ // "a[b][][c]" ==> ["a", "b", "", "c"]
102
+ static VALUE param_hash_split_name(VALUE _, VALUE name) {
103
+ Check_Type(name, T_STRING);
104
+ return _split_name(name);
105
+ }
106
+
107
+ // prereq: all elements in keys are string
108
+ static VALUE param_hash_nested_aref(volatile VALUE obj, VALUE keys) {
106
109
  Check_Type(keys, T_ARRAY);
107
- VALUE* arr = RARRAY_PTR(keys);
108
- long len = RARRAY_LEN(keys);
109
- if (!len) {
110
- rb_raise(rb_eArgError, "aset 0 length key");
111
- return Qnil;
110
+ VALUE* keys_ptr = RARRAY_PTR(keys);
111
+ long keys_len = RARRAY_LEN(keys);
112
+
113
+ for (long i = 0; i < keys_len; i++) {
114
+ volatile VALUE key = keys_ptr[i];
115
+ if (RSTRING_LEN(key)) {
116
+ if (rb_obj_is_kind_of(obj, rb_cHash)) {
117
+ obj = rb_hash_aref(obj, key);
118
+ } else {
119
+ return Qnil;
120
+ }
121
+ } else {
122
+ if (rb_obj_is_kind_of(obj, rb_cArray)) {
123
+ long arr_len = RARRAY_LEN(obj);
124
+ if (arr_len) {
125
+ obj = RARRAY_PTR(obj)[arr_len - 1];
126
+ } else {
127
+ return Qnil;
128
+ }
129
+ } else {
130
+ return Qnil;
131
+ }
132
+ }
112
133
  }
134
+ return obj;
135
+ }
136
+
137
+ // prereq: len > 0
138
+ static void _nested_aset(VALUE output, volatile VALUE keys, VALUE value) {
113
139
  volatile VALUE klass = rb_obj_class(output);
140
+ VALUE* arr = RARRAY_PTR(keys);
141
+ long len = RARRAY_LEN(keys);
114
142
 
115
143
  // first key seg
116
- long is_hash_key = 1;
144
+ if (!RSTRING_LEN(arr[0])) {
145
+ rb_raise(rb_eRuntimeError, "array key at:0 conflicts with hash");
146
+ }
147
+ bool is_hash_key = true;
148
+
149
+ # define NEW_CHILD(child) \
150
+ volatile VALUE child = (next_is_hash_key ? rb_class_new_instance(0, NULL, klass) : rb_ary_new());
151
+ # define ASSERT_HASH \
152
+ if (TYPE(output) != T_HASH) {\
153
+ rb_raise(rb_eTypeError, "hash key at:%ld conflicts with array", i + 1);\
154
+ }
155
+ # define ASSERT_ARRAY \
156
+ if (TYPE(output) != T_ARRAY) {\
157
+ rb_raise(rb_eTypeError, "array key at:%ld conflicts with hash", i + 1);\
158
+ }
159
+ # define CHECK_NEXT \
160
+ if (next_is_hash_key) {\
161
+ ASSERT_HASH;\
162
+ } else {\
163
+ ASSERT_ARRAY;\
164
+ }
165
+
166
+ // special treatment to array keys according to last 2 segments:
167
+ // *[][foo] append new hash if already exists
168
+ //
169
+ // normal cases:
170
+ // *[] just push
171
+ // *[foo] find last elem first
172
+ // *[]* find last elem first
117
173
 
118
174
  // middle key segs
119
175
  for (long i = 0; i < len - 1; i++) {
120
- long next_is_hash_key = RSTRING_LEN(arr[i + 1]);
121
- # define NEW_CHILD(child) \
122
- volatile VALUE child = (next_is_hash_key ? rb_class_new_instance(0, NULL, klass) : rb_ary_new());
123
-
176
+ bool next_is_hash_key = RSTRING_LEN(arr[i + 1]);
124
177
  if (is_hash_key) {
125
178
  if (nyara_rb_hash_has_key(output, arr[i])) {
126
179
  output = rb_hash_aref(output, arr[i]);
127
- if (next_is_hash_key) {
128
- if (TYPE(output) != T_HASH) {
129
- rb_raise(rb_eRuntimeError, "hash key at:%ld conflicts with array", i + 1);
180
+ CHECK_NEXT;
181
+ } else {
182
+ NEW_CHILD(child);
183
+ rb_hash_aset(output, arr[i], child);
184
+ output = child;
185
+ }
186
+ } else {
187
+ // array key, try to use the last elem
188
+ long output_len = RARRAY_LEN(output);
189
+ if (output_len) {
190
+ bool append = false;
191
+ if (i == len - 2 && next_is_hash_key) {
192
+ volatile VALUE next_hash = RARRAY_PTR(output)[output_len - 1];
193
+ if (nyara_rb_hash_has_key(next_hash, arr[i + 1])) {
194
+ append = true;
130
195
  }
196
+ }
197
+ if (append) {
198
+ volatile VALUE child = rb_class_new_instance(0, NULL, klass);
199
+ rb_ary_push(output, child);
200
+ output = child;
131
201
  } else {
132
- if (TYPE(output) != T_ARRAY) {
133
- rb_raise(rb_eRuntimeError, "array key at:%ld conflicts with hash", i + 1);
134
- }
202
+ output = RARRAY_PTR(output)[output_len - 1];
203
+ CHECK_NEXT;
135
204
  }
136
205
  } else {
137
206
  NEW_CHILD(child);
138
- rb_hash_aset(output, arr[i], child);
207
+ rb_ary_push(output, child);
139
208
  output = child;
140
209
  }
141
- } else {
142
- NEW_CHILD(child);
143
- rb_ary_push(output, child);
144
- output = child;
145
210
  }
146
211
  is_hash_key = next_is_hash_key;
147
- # undef NEW_CHILD
148
212
  }
149
213
 
150
- // terminate key seg: add value
214
+ # undef CHECK_NEXT
215
+ # undef ASSERT_ARRAY
216
+ # undef ASSERT_HASH
217
+ # undef NEW_CHILD
218
+
219
+ // terminate seg
151
220
  if (is_hash_key) {
152
221
  rb_hash_aset(output, arr[len - 1], value);
153
222
  } else {
154
223
  rb_ary_push(output, value);
155
224
  }
225
+ }
226
+
227
+ // prereq: all elements in keys are string
228
+ // assume keys = [a, b, c] ==> self[a][b][c] = value
229
+ // blank keys will be translated as array keys.
230
+ // created hashes has the same class with output
231
+ static VALUE param_hash_nested_aset(VALUE output, VALUE keys, VALUE value) {
232
+ Check_Type(keys, T_ARRAY);
233
+ long len = RARRAY_LEN(keys);
234
+ if (!len) {
235
+ rb_raise(rb_eArgError, "aset 0 length key");
236
+ return Qnil;
237
+ }
238
+ _nested_aset(output, keys, value);
156
239
  return output;
157
240
  }
158
241
 
159
242
  // s, len is the raw kv string
160
243
  // returns trailing length
161
- static void _kv(VALUE output, const char* s, long len, bool nested_mode) {
244
+ static void _cookie_kv(VALUE output, const char* s, long len) {
162
245
  // strip
163
246
  for (; len > 0; len--, s++) {
164
247
  if (!isspace(*s)) {
@@ -174,12 +257,7 @@ static void _kv(VALUE output, const char* s, long len, bool nested_mode) {
174
257
  volatile VALUE key = rb_enc_str_new("", 0, u8_encoding);
175
258
  volatile VALUE value = rb_enc_str_new("", 0, u8_encoding);
176
259
  nyara_decode_uri_kv(key, value, s, len);
177
- if (nested_mode) {
178
- volatile VALUE keys = param_hash_split_name(Qnil, key);
179
- param_hash_nested_aset(output, keys, value);
180
- } else {
181
- rb_hash_aset(output, key, value);
182
- }
260
+ rb_hash_aset(output, key, value);
183
261
  }
184
262
  }
185
263
 
@@ -201,17 +279,41 @@ static VALUE param_hash_parse_cookie(VALUE _, VALUE output, VALUE str) {
201
279
  for (; i >= 0; i--) {
202
280
  if (s[i] == ',' || s[i] == ';') {
203
281
  if (i < last_i) {
204
- _kv(output, s + i + 1, last_i - i, false);
282
+ _cookie_kv(output, s + i + 1, last_i - i);
205
283
  }
206
284
  last_i = i - 1;
207
285
  }
208
286
  }
209
287
  if (last_i > 0) {
210
- _kv(output, s, last_i + 1, false);
288
+ _cookie_kv(output, s, last_i + 1);
211
289
  }
212
290
  return output;
213
291
  }
214
292
 
293
+ // s, len is the raw kv string
294
+ // returns trailing length
295
+ static void _param_kv(VALUE output, const char* s, long len) {
296
+ // strip
297
+ for (; len > 0; len--, s++) {
298
+ if (!isspace(*s)) {
299
+ break;
300
+ }
301
+ }
302
+ for (; len > 0; len--) {
303
+ if (!isspace(s[len - 1])) {
304
+ break;
305
+ }
306
+ }
307
+ if (len <= 0) {
308
+ return;
309
+ }
310
+
311
+ volatile VALUE name = rb_enc_str_new("", 0, u8_encoding);
312
+ volatile VALUE value = rb_enc_str_new("", 0, u8_encoding);
313
+ nyara_decode_uri_kv(name, value, s, len);
314
+ _nested_aset(output, _split_name(name), value);
315
+ }
316
+
215
317
  // class method:
216
318
  // insert parsing result into output
217
319
  static VALUE param_hash_parse_param(VALUE _, VALUE output, VALUE str) {
@@ -229,13 +331,13 @@ static VALUE param_hash_parse_param(VALUE _, VALUE output, VALUE str) {
229
331
  for (; i < len; i++) {
230
332
  if (s[i] == '&' || s[i] == ';') {
231
333
  if (i > last_i) {
232
- _kv(output, s + last_i, i - last_i, true);
334
+ _param_kv(output, s + last_i, i - last_i);
233
335
  }
234
336
  last_i = i + 1;
235
337
  }
236
338
  }
237
339
  if (i > last_i) {
238
- _kv(output, s + last_i, i - last_i, true);
340
+ _param_kv(output, s + last_i, i - last_i);
239
341
  }
240
342
  return output;
241
343
  }
@@ -308,7 +410,7 @@ static VALUE header_hash_aset(VALUE self, VALUE key, VALUE value) {
308
410
  return rb_hash_aset(self, key, value);
309
411
  }
310
412
 
311
- static int header_hash_merge_func(VALUE k, VALUE v, VALUE self_st) {
413
+ static int _reverse_merge_func(VALUE k, VALUE v, VALUE self_st) {
312
414
  st_table* t = (st_table*)self_st;
313
415
  if (!st_is_member(t, k)) {
314
416
  st_insert(t, (st_data_t)k, (st_data_t)v);
@@ -321,11 +423,11 @@ static VALUE header_hash_reverse_merge_bang(VALUE self, VALUE other) {
321
423
  rb_raise(rb_eArgError, "need a Nyara::HeaderHash");
322
424
  }
323
425
  st_table* t = rb_hash_tbl(self);
324
- rb_hash_foreach(other, header_hash_merge_func, (VALUE)t);
426
+ rb_hash_foreach(other, _reverse_merge_func, (VALUE)t);
325
427
  return self;
326
428
  }
327
429
 
328
- static int header_hash_serialize_func(VALUE k, VALUE v, VALUE arr) {
430
+ static int _serialize_func(VALUE k, VALUE v, VALUE arr) {
329
431
  long vlen = RSTRING_LEN(v);
330
432
  // deleted field
331
433
  if (vlen == 0) {
@@ -349,7 +451,7 @@ static VALUE header_hash_serialize(VALUE self) {
349
451
  # else
350
452
  volatile VALUE arr = rb_ary_new();
351
453
  # endif
352
- rb_hash_foreach(self, header_hash_serialize_func, arr);
454
+ rb_hash_foreach(self, _serialize_func, arr);
353
455
  return arr;
354
456
  }
355
457
 
@@ -364,6 +466,7 @@ void Init_hashes(VALUE nyara) {
364
466
  rb_define_method(nyara_param_hash_class, "key?", param_hash_key_p, 1);
365
467
  rb_define_method(nyara_param_hash_class, "[]=", param_hash_aset, 2);
366
468
  rb_define_method(nyara_param_hash_class, "nested_aset", param_hash_nested_aset, 2);
469
+ rb_define_method(nyara_param_hash_class, "nested_aref", param_hash_nested_aref, 1);
367
470
  rb_define_singleton_method(nyara_param_hash_class, "split_name", param_hash_split_name, 1);
368
471
  rb_define_singleton_method(nyara_param_hash_class, "parse_param", param_hash_parse_param, 2);
369
472
  rb_define_singleton_method(nyara_param_hash_class, "parse_cookie", param_hash_parse_cookie, 2);
@@ -375,6 +478,6 @@ void Init_hashes(VALUE nyara) {
375
478
  rb_define_method(nyara_header_hash_class, "serialize", header_hash_serialize, 0);
376
479
 
377
480
  // for internal use
378
- rb_define_method(nyara_header_hash_class, "_aset", rb_hash_aset, 2);
379
- rb_define_method(nyara_header_hash_class, "_aref", rb_hash_aref, 1);
481
+ rb_define_method(nyara_param_hash_class, "_aset", rb_hash_aset, 2);
482
+ rb_define_method(nyara_param_hash_class, "_aref", rb_hash_aref, 1);
380
483
  }