mbrao 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +5 -0
  4. data/doc/ActionView/Template/Handlers/MbraoTemplate.html +87 -20
  5. data/doc/ActionView/Template/Handlers.html +1 -1
  6. data/doc/HTML/Pipeline/KramdownFilter.html +1 -1
  7. data/doc/HTML/Pipeline.html +1 -1
  8. data/doc/HTML.html +1 -1
  9. data/doc/Mbrao/Author.html +337 -67
  10. data/doc/Mbrao/Content.html +1268 -444
  11. data/doc/Mbrao/ContentPublicInterface.html +24 -20
  12. data/doc/Mbrao/Exceptions/InvalidDate.html +1 -1
  13. data/doc/Mbrao/Exceptions/InvalidMetadata.html +1 -1
  14. data/doc/Mbrao/Exceptions/Parsing.html +1 -1
  15. data/doc/Mbrao/Exceptions/Rendering.html +1 -1
  16. data/doc/Mbrao/Exceptions/UnavailableLocalization.html +1 -1
  17. data/doc/Mbrao/Exceptions/Unimplemented.html +1 -1
  18. data/doc/Mbrao/Exceptions/UnknownEngine.html +1 -1
  19. data/doc/Mbrao/Exceptions.html +1 -1
  20. data/doc/Mbrao/Parser.html +11 -11
  21. data/doc/Mbrao/ParsingEngines/Base.html +25 -24
  22. data/doc/Mbrao/ParsingEngines/PlainText.html +17 -16
  23. data/doc/Mbrao/ParsingEngines.html +1 -1
  24. data/doc/Mbrao/PublicInterface/ClassMethods.html +312 -19
  25. data/doc/Mbrao/PublicInterface.html +1 -1
  26. data/doc/Mbrao/RenderingEngines/Base.html +7 -7
  27. data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +27 -15
  28. data/doc/Mbrao/RenderingEngines.html +1 -1
  29. data/doc/Mbrao/Validations/ClassMethods.html +21 -21
  30. data/doc/Mbrao/Validations.html +1 -1
  31. data/doc/Mbrao/Version.html +3 -3
  32. data/doc/Mbrao.html +1 -1
  33. data/doc/_index.html +1 -1
  34. data/doc/file.README.html +1 -1
  35. data/doc/index.html +1 -1
  36. data/doc/method_list.html +86 -62
  37. data/doc/top-level-namespace.html +1 -1
  38. data/lib/mbrao/author.rb +18 -4
  39. data/lib/mbrao/content.rb +93 -44
  40. data/lib/mbrao/integrations/rails.rb +12 -5
  41. data/lib/mbrao/parser.rb +23 -0
  42. data/lib/mbrao/parsing_engines/base.rb +12 -11
  43. data/lib/mbrao/parsing_engines/plain_text.rb +29 -23
  44. data/lib/mbrao/rendering_engines/base.rb +4 -4
  45. data/lib/mbrao/rendering_engines/html_pipeline.rb +7 -2
  46. data/lib/mbrao/version.rb +2 -2
  47. data/spec/mbrao/author_spec.rb +32 -16
  48. data/spec/mbrao/content_spec.rb +144 -85
  49. data/spec/mbrao/integrations/rails_spec.rb +14 -0
  50. data/spec/mbrao/parser_spec.rb +19 -19
  51. data/spec/mbrao/parsing_engines/base_spec.rb +12 -12
  52. data/spec/mbrao/parsing_engines/plain_text_spec.rb +21 -21
  53. data/spec/mbrao/rendering_engines/base_spec.rb +2 -2
  54. data/spec/mbrao/rendering_engines/html_pipeline_spec.rb +31 -31
  55. metadata +2 -2
@@ -221,6 +221,29 @@
221
221
  <li class="public ">
222
222
  <span class="summary_signature">
223
223
 
224
+ <a href="#as_json-instance_method" title="#as_json (instance method)">- (Hash) <strong>as_json</strong>(target, keys, options = {}) </a>
225
+
226
+
227
+
228
+ </span>
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+ <span class="summary_desc"><div class='inline'><p>Returns an object as a JSON compatible hash.</p>
239
+ </div></span>
240
+
241
+ </li>
242
+
243
+
244
+ <li class="public ">
245
+ <span class="summary_signature">
246
+
224
247
  <a href="#create_engine-instance_method" title="#create_engine (instance method)">- (Object) <strong>create_engine</strong>(cls, type = :parsing) </a>
225
248
 
226
249
 
@@ -440,7 +463,30 @@
440
463
  97
441
464
  98
442
465
  99
443
- 100</pre>
466
+ 100
467
+ 101
468
+ 102
469
+ 103
470
+ 104
471
+ 105
472
+ 106
473
+ 107
474
+ 108
475
+ 109
476
+ 110
477
+ 111
478
+ 112
479
+ 113
480
+ 114
481
+ 115
482
+ 116
483
+ 117
484
+ 118
485
+ 119
486
+ 120
487
+ 121
488
+ 122
489
+ 123</pre>
444
490
  </td>
445
491
  <td>
446
492
  <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 21</span>
@@ -490,6 +536,29 @@
490
536
  <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
491
537
  <span class='kw'>end</span>
492
538
 
539
+ <span class='comment'># Returns an object as a JSON compatible hash
540
+ </span> <span class='comment'>#
541
+ </span> <span class='comment'># @param target [Object] The target to serialize.
542
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization
543
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
544
+ </span> <span class='comment'># The only supported value are:
545
+ </span> <span class='comment'>#
546
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
547
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
548
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
549
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
550
+ <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude_empty</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
551
+ <span class='id identifier rubyid_exclude'>exclude</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
552
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
553
+
554
+ <span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_exclude'>exclude</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
555
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
556
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:as_json</span><span class='rparen'>)</span>
557
+ <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>||</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>NilClass</span><span class='rparen'>)</span>
558
+ <span class='id identifier rubyid_rv'>rv</span>
559
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_deep_stringify_keys'>deep_stringify_keys</span>
560
+ <span class='kw'>end</span>
561
+
493
562
  <span class='comment'># Instantiates a new engine for rendering or parsing.
494
563
  </span> <span class='comment'>#
495
564
  </span> <span class='comment'># @param cls [String|Symbol|Object] If a `String` or a `Symbol`, then it will be the class of the engine.
@@ -712,7 +781,30 @@
712
781
  97
713
782
  98
714
783
  99
715
- 100</pre>
784
+ 100
785
+ 101
786
+ 102
787
+ 103
788
+ 104
789
+ 105
790
+ 106
791
+ 107
792
+ 108
793
+ 109
794
+ 110
795
+ 111
796
+ 112
797
+ 113
798
+ 114
799
+ 115
800
+ 116
801
+ 117
802
+ 118
803
+ 119
804
+ 120
805
+ 121
806
+ 122
807
+ 123</pre>
716
808
  </td>
717
809
  <td>
718
810
  <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 21</span>
@@ -762,6 +854,29 @@
762
854
  <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
763
855
  <span class='kw'>end</span>
764
856
 
857
+ <span class='comment'># Returns an object as a JSON compatible hash
858
+ </span> <span class='comment'>#
859
+ </span> <span class='comment'># @param target [Object] The target to serialize.
860
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization
861
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
862
+ </span> <span class='comment'># The only supported value are:
863
+ </span> <span class='comment'>#
864
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
865
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
866
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
867
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
868
+ <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude_empty</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
869
+ <span class='id identifier rubyid_exclude'>exclude</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
870
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
871
+
872
+ <span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_exclude'>exclude</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
873
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
874
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:as_json</span><span class='rparen'>)</span>
875
+ <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>||</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>NilClass</span><span class='rparen'>)</span>
876
+ <span class='id identifier rubyid_rv'>rv</span>
877
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_deep_stringify_keys'>deep_stringify_keys</span>
878
+ <span class='kw'>end</span>
879
+
765
880
  <span class='comment'># Instantiates a new engine for rendering or parsing.
766
881
  </span> <span class='comment'>#
767
882
  </span> <span class='comment'># @param cls [String|Symbol|Object] If a `String` or a `Symbol`, then it will be the class of the engine.
@@ -925,7 +1040,30 @@
925
1040
  97
926
1041
  98
927
1042
  99
928
- 100</pre>
1043
+ 100
1044
+ 101
1045
+ 102
1046
+ 103
1047
+ 104
1048
+ 105
1049
+ 106
1050
+ 107
1051
+ 108
1052
+ 109
1053
+ 110
1054
+ 111
1055
+ 112
1056
+ 113
1057
+ 114
1058
+ 115
1059
+ 116
1060
+ 117
1061
+ 118
1062
+ 119
1063
+ 120
1064
+ 121
1065
+ 122
1066
+ 123</pre>
929
1067
  </td>
930
1068
  <td>
931
1069
  <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 21</span>
@@ -975,6 +1113,29 @@
975
1113
  <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
976
1114
  <span class='kw'>end</span>
977
1115
 
1116
+ <span class='comment'># Returns an object as a JSON compatible hash
1117
+ </span> <span class='comment'>#
1118
+ </span> <span class='comment'># @param target [Object] The target to serialize.
1119
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization
1120
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
1121
+ </span> <span class='comment'># The only supported value are:
1122
+ </span> <span class='comment'>#
1123
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
1124
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
1125
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
1126
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1127
+ <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude_empty</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
1128
+ <span class='id identifier rubyid_exclude'>exclude</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1129
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1130
+
1131
+ <span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_exclude'>exclude</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
1132
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
1133
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:as_json</span><span class='rparen'>)</span>
1134
+ <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>||</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>NilClass</span><span class='rparen'>)</span>
1135
+ <span class='id identifier rubyid_rv'>rv</span>
1136
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_deep_stringify_keys'>deep_stringify_keys</span>
1137
+ <span class='kw'>end</span>
1138
+
978
1139
  <span class='comment'># Instantiates a new engine for rendering or parsing.
979
1140
  </span> <span class='comment'>#
980
1141
  </span> <span class='comment'># @param cls [String|Symbol|Object] If a `String` or a `Symbol`, then it will be the class of the engine.
@@ -1023,7 +1184,139 @@
1023
1184
 
1024
1185
 
1025
1186
  <div class="method_details first">
1026
- <h3 class="signature first" id="create_engine-instance_method">
1187
+ <h3 class="signature first" id="as_json-instance_method">
1188
+
1189
+ - (<tt>Hash</tt>) <strong>as_json</strong>(target, keys, options = {})
1190
+
1191
+
1192
+
1193
+
1194
+
1195
+ </h3><div class="docstring">
1196
+ <div class="discussion">
1197
+ <p>Returns an object as a JSON compatible hash</p>
1198
+
1199
+
1200
+ </div>
1201
+ </div>
1202
+ <div class="tags">
1203
+ <p class="tag_title">Parameters:</p>
1204
+ <ul class="param">
1205
+
1206
+ <li>
1207
+
1208
+ <span class='name'>target</span>
1209
+
1210
+
1211
+ <span class='type'>(<tt>Object</tt>)</span>
1212
+
1213
+
1214
+
1215
+ &mdash;
1216
+ <div class='inline'><p>The target to serialize.</p>
1217
+ </div>
1218
+
1219
+ </li>
1220
+
1221
+ <li>
1222
+
1223
+ <span class='name'>keys</span>
1224
+
1225
+
1226
+ <span class='type'>(<tt>Array</tt>)</span>
1227
+
1228
+
1229
+
1230
+ &mdash;
1231
+ <div class='inline'><p>The attributes to include in the serialization</p>
1232
+ </div>
1233
+
1234
+ </li>
1235
+
1236
+ <li>
1237
+
1238
+ <span class='name'>options</span>
1239
+
1240
+
1241
+ <span class='type'>(<tt>Hash</tt>)</span>
1242
+
1243
+
1244
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1245
+
1246
+
1247
+ &mdash;
1248
+ <div class='inline'><p>Options to modify behavior of the serialization.
1249
+ The only supported value are:</p>
1250
+
1251
+ <ul>
1252
+ <li><code>:exclude</code>, an array of attributes to skip.</li>
1253
+ <li><code>:exclude_empty</code>, if to exclude nil values. Default is <code>false</code>.</li>
1254
+ </ul>
1255
+ </div>
1256
+
1257
+ </li>
1258
+
1259
+ </ul>
1260
+
1261
+ <p class="tag_title">Returns:</p>
1262
+ <ul class="return">
1263
+
1264
+ <li>
1265
+
1266
+
1267
+ <span class='type'>(<tt>Hash</tt>)</span>
1268
+
1269
+
1270
+
1271
+ &mdash;
1272
+ <div class='inline'><p>An hash with all attributes.</p>
1273
+ </div>
1274
+
1275
+ </li>
1276
+
1277
+ </ul>
1278
+
1279
+ </div><table class="source_code">
1280
+ <tr>
1281
+ <td>
1282
+ <pre class="lines">
1283
+
1284
+
1285
+ 76
1286
+ 77
1287
+ 78
1288
+ 79
1289
+ 80
1290
+ 81
1291
+ 82
1292
+ 83
1293
+ 84
1294
+ 85
1295
+ 86
1296
+ 87</pre>
1297
+ </td>
1298
+ <td>
1299
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 76</span>
1300
+
1301
+ <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1302
+ <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude_empty</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
1303
+ <span class='id identifier rubyid_exclude'>exclude</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1304
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1305
+
1306
+ <span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_exclude'>exclude</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
1307
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
1308
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:as_json</span><span class='rparen'>)</span>
1309
+ <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>||</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>NilClass</span><span class='rparen'>)</span>
1310
+ <span class='id identifier rubyid_rv'>rv</span>
1311
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_deep_stringify_keys'>deep_stringify_keys</span>
1312
+ <span class='kw'>end</span></pre>
1313
+ </td>
1314
+ </tr>
1315
+ </table>
1316
+ </div>
1317
+
1318
+ <div class="method_details ">
1319
+ <h3 class="signature " id="create_engine-instance_method">
1027
1320
 
1028
1321
  - (<tt>Object</tt>) <strong>create_engine</strong>(cls, type = :parsing)
1029
1322
 
@@ -1100,17 +1393,17 @@
1100
1393
  <pre class="lines">
1101
1394
 
1102
1395
 
1103
- 71
1104
- 72
1105
- 73
1106
- 74
1107
- 75
1108
- 76
1109
- 77
1110
- 78</pre>
1396
+ 94
1397
+ 95
1398
+ 96
1399
+ 97
1400
+ 98
1401
+ 99
1402
+ 100
1403
+ 101</pre>
1111
1404
  </td>
1112
1405
  <td>
1113
- <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 71</span>
1406
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 94</span>
1114
1407
 
1115
1408
  <span class='kw'>def</span> <span class='id identifier rubyid_create_engine'>create_engine</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span><span class='rparen'>)</span>
1116
1409
  <span class='kw'>begin</span>
@@ -1188,13 +1481,13 @@
1188
1481
  <pre class="lines">
1189
1482
 
1190
1483
 
1191
- 84
1192
- 85
1193
- 86
1194
- 87</pre>
1484
+ 107
1485
+ 108
1486
+ 109
1487
+ 110</pre>
1195
1488
  </td>
1196
1489
  <td>
1197
- <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 84</span>
1490
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 107</span>
1198
1491
 
1199
1492
  <span class='kw'>def</span> <span class='id identifier rubyid_instance'>instance</span><span class='lparen'>(</span><span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
1200
1493
  <span class='ivar'>@instance</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_force'>force</span>
@@ -1413,7 +1706,7 @@
1413
1706
  </div>
1414
1707
 
1415
1708
  <div id="footer">
1416
- Generated on Sat Nov 23 13:44:01 2013 by
1709
+ Generated on Sun Nov 24 14:07:03 2013 by
1417
1710
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1418
1711
  0.8.7.3 (ruby-2.0.0).
1419
1712
  </div>
@@ -125,7 +125,7 @@
125
125
  </div>
126
126
 
127
127
  <div id="footer">
128
- Generated on Sat Nov 23 13:44:01 2013 by
128
+ Generated on Sun Nov 24 14:07:03 2013 by
129
129
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
130
130
  0.8.7.3 (ruby-2.0.0).
131
131
  </div>
@@ -131,7 +131,7 @@
131
131
  <li class="public ">
132
132
  <span class="summary_signature">
133
133
 
134
- <a href="#render-instance_method" title="#render (instance method)">- (Object) <strong>render</strong>(content, options = {}, context = {}) </a>
134
+ <a href="#render-instance_method" title="#render (instance method)">- (Object) <strong>render</strong>(_content, _options = {}, _context = {}) </a>
135
135
 
136
136
 
137
137
 
@@ -163,7 +163,7 @@
163
163
  <div class="method_details first">
164
164
  <h3 class="signature first" id="render-instance_method">
165
165
 
166
- - (<tt>Object</tt>) <strong>render</strong>(content, options = {}, context = {})
166
+ - (<tt>Object</tt>) <strong>render</strong>(_content, _options = {}, _context = {})
167
167
 
168
168
 
169
169
 
@@ -182,7 +182,7 @@
182
182
 
183
183
  <li>
184
184
 
185
- <span class='name'>content</span>
185
+ <span class='name'>_content</span>
186
186
 
187
187
 
188
188
  <span class='type'>(<tt><span class='object_link'><a href="../Content.html" title="Mbrao::Content (class)">Content</a></span>|String</tt>)</span>
@@ -197,7 +197,7 @@
197
197
 
198
198
  <li>
199
199
 
200
- <span class='name'>options</span>
200
+ <span class='name'>_options</span>
201
201
 
202
202
 
203
203
  <span class='type'>(<tt>Hash</tt>)</span>
@@ -214,7 +214,7 @@
214
214
 
215
215
  <li>
216
216
 
217
- <span class='name'>context</span>
217
+ <span class='name'>_context</span>
218
218
 
219
219
 
220
220
  <span class='type'>(<tt>Hash</tt>)</span>
@@ -258,7 +258,7 @@
258
258
  <td>
259
259
  <pre class="code"><span class="info file"># File 'lib/mbrao/rendering_engines/base.rb', line 17</span>
260
260
 
261
- <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
261
+ <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid__content'>_content</span><span class='comma'>,</span> <span class='id identifier rubyid__options'>_options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid__context'>_context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
262
262
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Unimplemented</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
263
263
  <span class='kw'>end</span></pre>
264
264
  </td>
@@ -271,7 +271,7 @@
271
271
  </div>
272
272
 
273
273
  <div id="footer">
274
- Generated on Sat Nov 23 13:44:02 2013 by
274
+ Generated on Sun Nov 24 14:07:04 2013 by
275
275
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
276
276
  0.8.7.3 (ruby-2.0.0).
277
277
  </div>