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
@@ -451,6 +451,29 @@
451
451
  <li class="public ">
452
452
  <span class="summary_signature">
453
453
 
454
+ <a href="#as_json-instance_method" title="#as_json (instance method)">- (Hash) <strong>as_json</strong>(options = {}) </a>
455
+
456
+
457
+
458
+ </span>
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+ <span class="summary_desc"><div class='inline'><p>Returns the content as an Hash.</p>
469
+ </div></span>
470
+
471
+ </li>
472
+
473
+
474
+ <li class="public ">
475
+ <span class="summary_signature">
476
+
454
477
  <a href="#initialize-instance_method" title="#initialize (instance method)">- (Content) <strong>initialize</strong>(uid = nil) </a>
455
478
 
456
479
 
@@ -536,12 +559,12 @@
536
559
  <pre class="lines">
537
560
 
538
561
 
539
- 124
540
- 125
541
- 126</pre>
562
+ 134
563
+ 135
564
+ 136</pre>
542
565
  </td>
543
566
  <td>
544
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 124</span>
567
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 134</span>
545
568
 
546
569
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_uid'>uid</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
547
570
  <span class='ivar'>@uid</span> <span class='op'>=</span> <span class='id identifier rubyid_uid'>uid</span>
@@ -600,16 +623,6 @@
600
623
  <pre class="lines">
601
624
 
602
625
 
603
- 107
604
- 108
605
- 109
606
- 110
607
- 111
608
- 112
609
- 113
610
- 114
611
- 115
612
- 116
613
626
  117
614
627
  118
615
628
  119
@@ -790,10 +803,59 @@
790
803
  294
791
804
  295
792
805
  296
793
- 297</pre>
806
+ 297
807
+ 298
808
+ 299
809
+ 300
810
+ 301
811
+ 302
812
+ 303
813
+ 304
814
+ 305
815
+ 306
816
+ 307
817
+ 308
818
+ 309
819
+ 310
820
+ 311
821
+ 312
822
+ 313
823
+ 314
824
+ 315
825
+ 316
826
+ 317
827
+ 318
828
+ 319
829
+ 320
830
+ 321
831
+ 322
832
+ 323
833
+ 324
834
+ 325
835
+ 326
836
+ 327
837
+ 328
838
+ 329
839
+ 330
840
+ 331
841
+ 332
842
+ 333
843
+ 334
844
+ 335
845
+ 336
846
+ 337
847
+ 338
848
+ 339
849
+ 340
850
+ 341
851
+ 342
852
+ 343
853
+ 344
854
+ 345
855
+ 346</pre>
794
856
  </td>
795
857
  <td>
796
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
858
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
797
859
 
798
860
  <span class='kw'>class</span> <span class='const'>Content</span>
799
861
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -825,9 +887,10 @@
825
887
 
826
888
  <span class='comment'># Sets the `title` attribute.
827
889
  </span> <span class='comment'>#
828
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
829
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
830
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
890
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
891
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
892
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
893
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
831
894
  <span class='kw'>end</span>
832
895
 
833
896
  <span class='comment'># Sets the `body` attribute.
@@ -839,33 +902,35 @@
839
902
 
840
903
  <span class='comment'># Sets the `tags` attribute.
841
904
  </span> <span class='comment'>#
842
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
843
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
844
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
845
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
905
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
906
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
907
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
908
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
909
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
846
910
  <span class='kw'>else</span>
847
- <span class='id identifier rubyid_value'>value</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>
911
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
848
912
  <span class='kw'>end</span>
849
913
  <span class='kw'>end</span>
850
914
 
851
915
  <span class='comment'># Sets the `more` attribute.
852
916
  </span> <span class='comment'>#
853
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
854
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
855
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
917
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
918
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
919
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
920
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
856
921
  <span class='kw'>end</span>
857
922
 
858
923
  <span class='comment'># Sets the `author` attribute.
859
924
  </span> <span class='comment'>#
860
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
861
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
862
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
863
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
864
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
865
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
866
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
925
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
926
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
927
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
928
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
929
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
930
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
931
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
867
932
  <span class='kw'>else</span>
868
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
933
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
869
934
  <span class='kw'>end</span>
870
935
  <span class='kw'>end</span>
871
936
 
@@ -893,18 +958,32 @@
893
958
 
894
959
  <span class='comment'># Sets the `metadata` attribute.
895
960
  </span> <span class='comment'>#
896
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
897
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
898
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
899
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
961
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
962
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
963
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
964
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
900
965
  <span class='kw'>else</span>
901
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
966
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
902
967
  <span class='kw'>end</span>
903
968
  <span class='kw'>end</span>
904
969
 
970
+ <span class='comment'># Returns the content as an Hash.
971
+ </span> <span class='comment'>#
972
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
973
+ </span> <span class='comment'># The only supported value are:
974
+ </span> <span class='comment'>#
975
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
976
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
977
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
978
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
979
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
980
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
981
+ <span class='kw'>end</span>
982
+
905
983
  <span class='comment'># Validates locales for attribute retrieval.
906
984
  </span> <span class='comment'>#
907
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
985
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
986
+ </span> <span class='comment'># used.
908
987
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
909
988
  </span> <span class='comment'># @return [Array] The validated list of locales.
910
989
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -969,22 +1048,44 @@
969
1048
  <span class='comment'># Extracts a date and time from a value.
970
1049
  </span> <span class='comment'>#
971
1050
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
972
- </span> <span class='comment'># @return [DateTime] The extract values.
1051
+ </span> <span class='comment'># @return [DateTime] The extracted value.
973
1052
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
974
1053
  <span class='kw'>begin</span>
975
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
976
- <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_to_datetime'>to_datetime</span>
977
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
978
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
979
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
980
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
981
- <span class='kw'>end</span>
982
-
1054
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
983
1055
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
984
1056
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
985
1057
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
986
1058
  <span class='kw'>end</span>
987
1059
  <span class='kw'>end</span>
1060
+
1061
+ <span class='comment'># Parse a datetime
1062
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1063
+ </span> <span class='comment'># @return [DateTime] The extracted value.
1064
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1065
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
1066
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
1067
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
1068
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
1069
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
1070
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1071
+ <span class='kw'>end</span>
1072
+ <span class='kw'>end</span>
1073
+
1074
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
1075
+ </span> <span class='comment'>#
1076
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
1077
+ </span> <span class='comment'># @return [Array] The list of tags.
1078
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1079
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1080
+ <span class='kw'>end</span>
1081
+
1082
+ <span class='comment'># Check if value is an Hash.
1083
+ </span> <span class='comment'>#
1084
+ </span> <span class='comment'># @param value [Object] The object to check.
1085
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
1086
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1087
+ <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'>Hash</span><span class='rparen'>)</span>
1088
+ <span class='kw'>end</span>
988
1089
  <span class='kw'>end</span></pre>
989
1090
  </td>
990
1091
  </tr>
@@ -1004,7 +1105,8 @@
1004
1105
 
1005
1106
  </h3><div class="docstring">
1006
1107
  <div class="discussion">
1007
- <p>Returns The content’s body. Can be a <code>String</code> or an <code>HashWithIndifferentAccess</code>, if multiple contents are specified for multiple locales.</p>
1108
+ <p>Returns The content’s body. Can be a <code>String</code> or an <code>HashWithIndifferentAccess</code>, if multiple contents are specified
1109
+ for multiple locales.</p>
1008
1110
 
1009
1111
 
1010
1112
  </div>
@@ -1022,7 +1124,8 @@
1022
1124
 
1023
1125
 
1024
1126
  &mdash;
1025
- <div class='inline'><p>The content’s body. Can be a <code>String</code> or an <code>HashWithIndifferentAccess</code>, if multiple contents are specified for multiple locales.</p>
1127
+ <div class='inline'><p>The content’s body. Can be a <code>String</code> or an <code>HashWithIndifferentAccess</code>, if multiple contents are specified
1128
+ for multiple locales.</p>
1026
1129
  </div>
1027
1130
 
1028
1131
  </li>
@@ -1035,16 +1138,6 @@
1035
1138
  <pre class="lines">
1036
1139
 
1037
1140
 
1038
- 107
1039
- 108
1040
- 109
1041
- 110
1042
- 111
1043
- 112
1044
- 113
1045
- 114
1046
- 115
1047
- 116
1048
1141
  117
1049
1142
  118
1050
1143
  119
@@ -1225,10 +1318,59 @@
1225
1318
  294
1226
1319
  295
1227
1320
  296
1228
- 297</pre>
1321
+ 297
1322
+ 298
1323
+ 299
1324
+ 300
1325
+ 301
1326
+ 302
1327
+ 303
1328
+ 304
1329
+ 305
1330
+ 306
1331
+ 307
1332
+ 308
1333
+ 309
1334
+ 310
1335
+ 311
1336
+ 312
1337
+ 313
1338
+ 314
1339
+ 315
1340
+ 316
1341
+ 317
1342
+ 318
1343
+ 319
1344
+ 320
1345
+ 321
1346
+ 322
1347
+ 323
1348
+ 324
1349
+ 325
1350
+ 326
1351
+ 327
1352
+ 328
1353
+ 329
1354
+ 330
1355
+ 331
1356
+ 332
1357
+ 333
1358
+ 334
1359
+ 335
1360
+ 336
1361
+ 337
1362
+ 338
1363
+ 339
1364
+ 340
1365
+ 341
1366
+ 342
1367
+ 343
1368
+ 344
1369
+ 345
1370
+ 346</pre>
1229
1371
  </td>
1230
1372
  <td>
1231
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
1373
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
1232
1374
 
1233
1375
  <span class='kw'>class</span> <span class='const'>Content</span>
1234
1376
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -1260,9 +1402,10 @@
1260
1402
 
1261
1403
  <span class='comment'># Sets the `title` attribute.
1262
1404
  </span> <span class='comment'>#
1263
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
1264
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1265
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1405
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
1406
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1407
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
1408
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1266
1409
  <span class='kw'>end</span>
1267
1410
 
1268
1411
  <span class='comment'># Sets the `body` attribute.
@@ -1274,33 +1417,35 @@
1274
1417
 
1275
1418
  <span class='comment'># Sets the `tags` attribute.
1276
1419
  </span> <span class='comment'>#
1277
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
1278
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1279
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
1280
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
1420
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
1421
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
1422
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
1423
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
1424
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1281
1425
  <span class='kw'>else</span>
1282
- <span class='id identifier rubyid_value'>value</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>
1426
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
1283
1427
  <span class='kw'>end</span>
1284
1428
  <span class='kw'>end</span>
1285
1429
 
1286
1430
  <span class='comment'># Sets the `more` attribute.
1287
1431
  </span> <span class='comment'>#
1288
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
1289
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1290
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1432
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
1433
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1434
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
1435
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1291
1436
  <span class='kw'>end</span>
1292
1437
 
1293
1438
  <span class='comment'># Sets the `author` attribute.
1294
1439
  </span> <span class='comment'>#
1295
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
1296
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1297
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
1298
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
1299
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
1300
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
1301
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
1440
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
1441
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
1442
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
1443
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
1444
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
1445
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
1446
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
1302
1447
  <span class='kw'>else</span>
1303
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
1448
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
1304
1449
  <span class='kw'>end</span>
1305
1450
  <span class='kw'>end</span>
1306
1451
 
@@ -1328,18 +1473,32 @@
1328
1473
 
1329
1474
  <span class='comment'># Sets the `metadata` attribute.
1330
1475
  </span> <span class='comment'>#
1331
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
1332
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1333
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
1334
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
1476
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
1477
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
1478
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
1479
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
1335
1480
  <span class='kw'>else</span>
1336
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1481
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1337
1482
  <span class='kw'>end</span>
1338
1483
  <span class='kw'>end</span>
1339
1484
 
1485
+ <span class='comment'># Returns the content as an Hash.
1486
+ </span> <span class='comment'>#
1487
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
1488
+ </span> <span class='comment'># The only supported value are:
1489
+ </span> <span class='comment'>#
1490
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
1491
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
1492
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
1493
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1494
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
1495
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
1496
+ <span class='kw'>end</span>
1497
+
1340
1498
  <span class='comment'># Validates locales for attribute retrieval.
1341
1499
  </span> <span class='comment'>#
1342
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
1500
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
1501
+ </span> <span class='comment'># used.
1343
1502
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
1344
1503
  </span> <span class='comment'># @return [Array] The validated list of locales.
1345
1504
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -1404,22 +1563,44 @@
1404
1563
  <span class='comment'># Extracts a date and time from a value.
1405
1564
  </span> <span class='comment'>#
1406
1565
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1407
- </span> <span class='comment'># @return [DateTime] The extract values.
1566
+ </span> <span class='comment'># @return [DateTime] The extracted value.
1408
1567
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1409
1568
  <span class='kw'>begin</span>
1410
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
1411
- <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_to_datetime'>to_datetime</span>
1412
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
1413
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
1414
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
1415
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1416
- <span class='kw'>end</span>
1417
-
1569
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
1418
1570
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
1419
1571
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
1420
1572
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1421
1573
  <span class='kw'>end</span>
1422
1574
  <span class='kw'>end</span>
1575
+
1576
+ <span class='comment'># Parse a datetime
1577
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1578
+ </span> <span class='comment'># @return [DateTime] The extracted value.
1579
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1580
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
1581
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
1582
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
1583
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
1584
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
1585
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1586
+ <span class='kw'>end</span>
1587
+ <span class='kw'>end</span>
1588
+
1589
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
1590
+ </span> <span class='comment'>#
1591
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
1592
+ </span> <span class='comment'># @return [Array] The list of tags.
1593
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1594
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1595
+ <span class='kw'>end</span>
1596
+
1597
+ <span class='comment'># Check if value is an Hash.
1598
+ </span> <span class='comment'>#
1599
+ </span> <span class='comment'># @param value [Object] The object to check.
1600
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
1601
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1602
+ <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'>Hash</span><span class='rparen'>)</span>
1603
+ <span class='kw'>end</span>
1423
1604
  <span class='kw'>end</span></pre>
1424
1605
  </td>
1425
1606
  </tr>
@@ -1470,16 +1651,6 @@
1470
1651
  <pre class="lines">
1471
1652
 
1472
1653
 
1473
- 107
1474
- 108
1475
- 109
1476
- 110
1477
- 111
1478
- 112
1479
- 113
1480
- 114
1481
- 115
1482
- 116
1483
1654
  117
1484
1655
  118
1485
1656
  119
@@ -1660,10 +1831,59 @@
1660
1831
  294
1661
1832
  295
1662
1833
  296
1663
- 297</pre>
1834
+ 297
1835
+ 298
1836
+ 299
1837
+ 300
1838
+ 301
1839
+ 302
1840
+ 303
1841
+ 304
1842
+ 305
1843
+ 306
1844
+ 307
1845
+ 308
1846
+ 309
1847
+ 310
1848
+ 311
1849
+ 312
1850
+ 313
1851
+ 314
1852
+ 315
1853
+ 316
1854
+ 317
1855
+ 318
1856
+ 319
1857
+ 320
1858
+ 321
1859
+ 322
1860
+ 323
1861
+ 324
1862
+ 325
1863
+ 326
1864
+ 327
1865
+ 328
1866
+ 329
1867
+ 330
1868
+ 331
1869
+ 332
1870
+ 333
1871
+ 334
1872
+ 335
1873
+ 336
1874
+ 337
1875
+ 338
1876
+ 339
1877
+ 340
1878
+ 341
1879
+ 342
1880
+ 343
1881
+ 344
1882
+ 345
1883
+ 346</pre>
1664
1884
  </td>
1665
1885
  <td>
1666
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
1886
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
1667
1887
 
1668
1888
  <span class='kw'>class</span> <span class='const'>Content</span>
1669
1889
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -1695,9 +1915,10 @@
1695
1915
 
1696
1916
  <span class='comment'># Sets the `title` attribute.
1697
1917
  </span> <span class='comment'>#
1698
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
1699
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1700
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1918
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
1919
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1920
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
1921
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1701
1922
  <span class='kw'>end</span>
1702
1923
 
1703
1924
  <span class='comment'># Sets the `body` attribute.
@@ -1709,33 +1930,35 @@
1709
1930
 
1710
1931
  <span class='comment'># Sets the `tags` attribute.
1711
1932
  </span> <span class='comment'>#
1712
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
1713
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1714
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
1715
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
1933
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
1934
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
1935
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
1936
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
1937
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1716
1938
  <span class='kw'>else</span>
1717
- <span class='id identifier rubyid_value'>value</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>
1939
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
1718
1940
  <span class='kw'>end</span>
1719
1941
  <span class='kw'>end</span>
1720
1942
 
1721
1943
  <span class='comment'># Sets the `more` attribute.
1722
1944
  </span> <span class='comment'>#
1723
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
1724
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1725
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1945
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
1946
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1947
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
1948
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1726
1949
  <span class='kw'>end</span>
1727
1950
 
1728
1951
  <span class='comment'># Sets the `author` attribute.
1729
1952
  </span> <span class='comment'>#
1730
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
1731
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1732
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
1733
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
1734
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
1735
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
1736
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
1953
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
1954
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
1955
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
1956
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
1957
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
1958
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
1959
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
1737
1960
  <span class='kw'>else</span>
1738
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
1961
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
1739
1962
  <span class='kw'>end</span>
1740
1963
  <span class='kw'>end</span>
1741
1964
 
@@ -1763,18 +1986,32 @@
1763
1986
 
1764
1987
  <span class='comment'># Sets the `metadata` attribute.
1765
1988
  </span> <span class='comment'>#
1766
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
1767
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1768
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
1769
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
1989
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
1990
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
1991
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
1992
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
1770
1993
  <span class='kw'>else</span>
1771
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1994
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1772
1995
  <span class='kw'>end</span>
1773
1996
  <span class='kw'>end</span>
1774
1997
 
1998
+ <span class='comment'># Returns the content as an Hash.
1999
+ </span> <span class='comment'>#
2000
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
2001
+ </span> <span class='comment'># The only supported value are:
2002
+ </span> <span class='comment'>#
2003
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
2004
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
2005
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
2006
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
2007
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
2008
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
2009
+ <span class='kw'>end</span>
2010
+
1775
2011
  <span class='comment'># Validates locales for attribute retrieval.
1776
2012
  </span> <span class='comment'>#
1777
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
2013
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
2014
+ </span> <span class='comment'># used.
1778
2015
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
1779
2016
  </span> <span class='comment'># @return [Array] The validated list of locales.
1780
2017
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -1839,22 +2076,44 @@
1839
2076
  <span class='comment'># Extracts a date and time from a value.
1840
2077
  </span> <span class='comment'>#
1841
2078
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1842
- </span> <span class='comment'># @return [DateTime] The extract values.
2079
+ </span> <span class='comment'># @return [DateTime] The extracted value.
1843
2080
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1844
2081
  <span class='kw'>begin</span>
1845
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
1846
- <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_to_datetime'>to_datetime</span>
1847
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
1848
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
1849
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
1850
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1851
- <span class='kw'>end</span>
1852
-
2082
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
1853
2083
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
1854
2084
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
1855
2085
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1856
2086
  <span class='kw'>end</span>
1857
2087
  <span class='kw'>end</span>
2088
+
2089
+ <span class='comment'># Parse a datetime
2090
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2091
+ </span> <span class='comment'># @return [DateTime] The extracted value.
2092
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2093
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
2094
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
2095
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
2096
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
2097
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
2098
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
2099
+ <span class='kw'>end</span>
2100
+ <span class='kw'>end</span>
2101
+
2102
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
2103
+ </span> <span class='comment'>#
2104
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
2105
+ </span> <span class='comment'># @return [Array] The list of tags.
2106
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2107
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
2108
+ <span class='kw'>end</span>
2109
+
2110
+ <span class='comment'># Check if value is an Hash.
2111
+ </span> <span class='comment'>#
2112
+ </span> <span class='comment'># @param value [Object] The object to check.
2113
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
2114
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2115
+ <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'>Hash</span><span class='rparen'>)</span>
2116
+ <span class='kw'>end</span>
1858
2117
  <span class='kw'>end</span></pre>
1859
2118
  </td>
1860
2119
  </tr>
@@ -1905,16 +2164,6 @@
1905
2164
  <pre class="lines">
1906
2165
 
1907
2166
 
1908
- 107
1909
- 108
1910
- 109
1911
- 110
1912
- 111
1913
- 112
1914
- 113
1915
- 114
1916
- 115
1917
- 116
1918
2167
  117
1919
2168
  118
1920
2169
  119
@@ -2095,10 +2344,59 @@
2095
2344
  294
2096
2345
  295
2097
2346
  296
2098
- 297</pre>
2347
+ 297
2348
+ 298
2349
+ 299
2350
+ 300
2351
+ 301
2352
+ 302
2353
+ 303
2354
+ 304
2355
+ 305
2356
+ 306
2357
+ 307
2358
+ 308
2359
+ 309
2360
+ 310
2361
+ 311
2362
+ 312
2363
+ 313
2364
+ 314
2365
+ 315
2366
+ 316
2367
+ 317
2368
+ 318
2369
+ 319
2370
+ 320
2371
+ 321
2372
+ 322
2373
+ 323
2374
+ 324
2375
+ 325
2376
+ 326
2377
+ 327
2378
+ 328
2379
+ 329
2380
+ 330
2381
+ 331
2382
+ 332
2383
+ 333
2384
+ 334
2385
+ 335
2386
+ 336
2387
+ 337
2388
+ 338
2389
+ 339
2390
+ 340
2391
+ 341
2392
+ 342
2393
+ 343
2394
+ 344
2395
+ 345
2396
+ 346</pre>
2099
2397
  </td>
2100
2398
  <td>
2101
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
2399
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
2102
2400
 
2103
2401
  <span class='kw'>class</span> <span class='const'>Content</span>
2104
2402
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -2130,9 +2428,10 @@
2130
2428
 
2131
2429
  <span class='comment'># Sets the `title` attribute.
2132
2430
  </span> <span class='comment'>#
2133
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
2134
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2135
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2431
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
2432
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2433
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
2434
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2136
2435
  <span class='kw'>end</span>
2137
2436
 
2138
2437
  <span class='comment'># Sets the `body` attribute.
@@ -2144,33 +2443,35 @@
2144
2443
 
2145
2444
  <span class='comment'># Sets the `tags` attribute.
2146
2445
  </span> <span class='comment'>#
2147
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
2148
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2149
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
2150
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
2446
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
2447
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
2448
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
2449
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
2450
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
2151
2451
  <span class='kw'>else</span>
2152
- <span class='id identifier rubyid_value'>value</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>
2452
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
2153
2453
  <span class='kw'>end</span>
2154
2454
  <span class='kw'>end</span>
2155
2455
 
2156
2456
  <span class='comment'># Sets the `more` attribute.
2157
2457
  </span> <span class='comment'>#
2158
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
2159
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2160
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2458
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
2459
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2460
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
2461
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2161
2462
  <span class='kw'>end</span>
2162
2463
 
2163
2464
  <span class='comment'># Sets the `author` attribute.
2164
2465
  </span> <span class='comment'>#
2165
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
2166
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2167
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
2168
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
2169
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
2170
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
2171
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
2466
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
2467
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
2468
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
2469
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
2470
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
2471
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
2472
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
2172
2473
  <span class='kw'>else</span>
2173
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
2474
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
2174
2475
  <span class='kw'>end</span>
2175
2476
  <span class='kw'>end</span>
2176
2477
 
@@ -2198,18 +2499,32 @@
2198
2499
 
2199
2500
  <span class='comment'># Sets the `metadata` attribute.
2200
2501
  </span> <span class='comment'>#
2201
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
2202
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2203
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
2204
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
2502
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
2503
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
2504
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
2505
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
2205
2506
  <span class='kw'>else</span>
2206
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
2507
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
2207
2508
  <span class='kw'>end</span>
2208
2509
  <span class='kw'>end</span>
2209
2510
 
2511
+ <span class='comment'># Returns the content as an Hash.
2512
+ </span> <span class='comment'>#
2513
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
2514
+ </span> <span class='comment'># The only supported value are:
2515
+ </span> <span class='comment'>#
2516
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
2517
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
2518
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
2519
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
2520
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
2521
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
2522
+ <span class='kw'>end</span>
2523
+
2210
2524
  <span class='comment'># Validates locales for attribute retrieval.
2211
2525
  </span> <span class='comment'>#
2212
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
2526
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
2527
+ </span> <span class='comment'># used.
2213
2528
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
2214
2529
  </span> <span class='comment'># @return [Array] The validated list of locales.
2215
2530
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -2274,22 +2589,44 @@
2274
2589
  <span class='comment'># Extracts a date and time from a value.
2275
2590
  </span> <span class='comment'>#
2276
2591
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2277
- </span> <span class='comment'># @return [DateTime] The extract values.
2592
+ </span> <span class='comment'># @return [DateTime] The extracted value.
2278
2593
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2279
2594
  <span class='kw'>begin</span>
2280
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
2281
- <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_to_datetime'>to_datetime</span>
2282
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
2283
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
2284
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
2285
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
2286
- <span class='kw'>end</span>
2287
-
2595
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
2288
2596
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
2289
2597
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
2290
2598
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
2291
2599
  <span class='kw'>end</span>
2292
2600
  <span class='kw'>end</span>
2601
+
2602
+ <span class='comment'># Parse a datetime
2603
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2604
+ </span> <span class='comment'># @return [DateTime] The extracted value.
2605
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2606
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
2607
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
2608
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
2609
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
2610
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
2611
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
2612
+ <span class='kw'>end</span>
2613
+ <span class='kw'>end</span>
2614
+
2615
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
2616
+ </span> <span class='comment'>#
2617
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
2618
+ </span> <span class='comment'># @return [Array] The list of tags.
2619
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2620
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
2621
+ <span class='kw'>end</span>
2622
+
2623
+ <span class='comment'># Check if value is an Hash.
2624
+ </span> <span class='comment'>#
2625
+ </span> <span class='comment'># @param value [Object] The object to check.
2626
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
2627
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2628
+ <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'>Hash</span><span class='rparen'>)</span>
2629
+ <span class='kw'>end</span>
2293
2630
  <span class='kw'>end</span></pre>
2294
2631
  </td>
2295
2632
  </tr>
@@ -2340,16 +2677,6 @@
2340
2677
  <pre class="lines">
2341
2678
 
2342
2679
 
2343
- 107
2344
- 108
2345
- 109
2346
- 110
2347
- 111
2348
- 112
2349
- 113
2350
- 114
2351
- 115
2352
- 116
2353
2680
  117
2354
2681
  118
2355
2682
  119
@@ -2530,10 +2857,59 @@
2530
2857
  294
2531
2858
  295
2532
2859
  296
2533
- 297</pre>
2860
+ 297
2861
+ 298
2862
+ 299
2863
+ 300
2864
+ 301
2865
+ 302
2866
+ 303
2867
+ 304
2868
+ 305
2869
+ 306
2870
+ 307
2871
+ 308
2872
+ 309
2873
+ 310
2874
+ 311
2875
+ 312
2876
+ 313
2877
+ 314
2878
+ 315
2879
+ 316
2880
+ 317
2881
+ 318
2882
+ 319
2883
+ 320
2884
+ 321
2885
+ 322
2886
+ 323
2887
+ 324
2888
+ 325
2889
+ 326
2890
+ 327
2891
+ 328
2892
+ 329
2893
+ 330
2894
+ 331
2895
+ 332
2896
+ 333
2897
+ 334
2898
+ 335
2899
+ 336
2900
+ 337
2901
+ 338
2902
+ 339
2903
+ 340
2904
+ 341
2905
+ 342
2906
+ 343
2907
+ 344
2908
+ 345
2909
+ 346</pre>
2534
2910
  </td>
2535
2911
  <td>
2536
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
2912
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
2537
2913
 
2538
2914
  <span class='kw'>class</span> <span class='const'>Content</span>
2539
2915
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -2565,9 +2941,10 @@
2565
2941
 
2566
2942
  <span class='comment'># Sets the `title` attribute.
2567
2943
  </span> <span class='comment'>#
2568
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
2569
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2570
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2944
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
2945
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2946
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
2947
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2571
2948
  <span class='kw'>end</span>
2572
2949
 
2573
2950
  <span class='comment'># Sets the `body` attribute.
@@ -2579,33 +2956,35 @@
2579
2956
 
2580
2957
  <span class='comment'># Sets the `tags` attribute.
2581
2958
  </span> <span class='comment'>#
2582
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
2583
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2584
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
2585
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
2959
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
2960
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
2961
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
2962
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
2963
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
2586
2964
  <span class='kw'>else</span>
2587
- <span class='id identifier rubyid_value'>value</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>
2965
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
2588
2966
  <span class='kw'>end</span>
2589
2967
  <span class='kw'>end</span>
2590
2968
 
2591
2969
  <span class='comment'># Sets the `more` attribute.
2592
2970
  </span> <span class='comment'>#
2593
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
2594
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2595
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2971
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
2972
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2973
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
2974
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2596
2975
  <span class='kw'>end</span>
2597
2976
 
2598
2977
  <span class='comment'># Sets the `author` attribute.
2599
2978
  </span> <span class='comment'>#
2600
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
2601
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2602
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
2603
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
2604
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
2605
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
2606
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
2979
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
2980
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
2981
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
2982
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
2983
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
2984
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
2985
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
2607
2986
  <span class='kw'>else</span>
2608
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
2987
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
2609
2988
  <span class='kw'>end</span>
2610
2989
  <span class='kw'>end</span>
2611
2990
 
@@ -2633,18 +3012,32 @@
2633
3012
 
2634
3013
  <span class='comment'># Sets the `metadata` attribute.
2635
3014
  </span> <span class='comment'>#
2636
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
2637
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2638
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
2639
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3015
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
3016
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
3017
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
3018
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
2640
3019
  <span class='kw'>else</span>
2641
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
3020
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
2642
3021
  <span class='kw'>end</span>
2643
3022
  <span class='kw'>end</span>
2644
3023
 
3024
+ <span class='comment'># Returns the content as an Hash.
3025
+ </span> <span class='comment'>#
3026
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
3027
+ </span> <span class='comment'># The only supported value are:
3028
+ </span> <span class='comment'>#
3029
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
3030
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
3031
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
3032
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
3033
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
3034
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
3035
+ <span class='kw'>end</span>
3036
+
2645
3037
  <span class='comment'># Validates locales for attribute retrieval.
2646
3038
  </span> <span class='comment'>#
2647
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
3039
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
3040
+ </span> <span class='comment'># used.
2648
3041
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
2649
3042
  </span> <span class='comment'># @return [Array] The validated list of locales.
2650
3043
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -2709,22 +3102,44 @@
2709
3102
  <span class='comment'># Extracts a date and time from a value.
2710
3103
  </span> <span class='comment'>#
2711
3104
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2712
- </span> <span class='comment'># @return [DateTime] The extract values.
3105
+ </span> <span class='comment'># @return [DateTime] The extracted value.
2713
3106
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2714
3107
  <span class='kw'>begin</span>
2715
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
2716
- <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_to_datetime'>to_datetime</span>
2717
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
2718
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
2719
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
2720
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
2721
- <span class='kw'>end</span>
2722
-
3108
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
2723
3109
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
2724
3110
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
2725
3111
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
2726
3112
  <span class='kw'>end</span>
2727
3113
  <span class='kw'>end</span>
3114
+
3115
+ <span class='comment'># Parse a datetime
3116
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3117
+ </span> <span class='comment'># @return [DateTime] The extracted value.
3118
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3119
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
3120
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
3121
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
3122
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
3123
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
3124
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
3125
+ <span class='kw'>end</span>
3126
+ <span class='kw'>end</span>
3127
+
3128
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
3129
+ </span> <span class='comment'>#
3130
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
3131
+ </span> <span class='comment'># @return [Array] The list of tags.
3132
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3133
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
3134
+ <span class='kw'>end</span>
3135
+
3136
+ <span class='comment'># Check if value is an Hash.
3137
+ </span> <span class='comment'>#
3138
+ </span> <span class='comment'># @param value [Object] The object to check.
3139
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
3140
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3141
+ <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'>Hash</span><span class='rparen'>)</span>
3142
+ <span class='kw'>end</span>
2728
3143
  <span class='kw'>end</span></pre>
2729
3144
  </td>
2730
3145
  </tr>
@@ -2758,12 +3173,12 @@
2758
3173
  <pre class="lines">
2759
3174
 
2760
3175
 
2761
- 115
2762
- 116
2763
- 117</pre>
3176
+ 125
3177
+ 126
3178
+ 127</pre>
2764
3179
  </td>
2765
3180
  <td>
2766
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 115</span>
3181
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 125</span>
2767
3182
 
2768
3183
  <span class='kw'>def</span> <span class='id identifier rubyid_more'>more</span>
2769
3184
  <span class='ivar'>@more</span>
@@ -2786,7 +3201,8 @@
2786
3201
 
2787
3202
  </h3><div class="docstring">
2788
3203
  <div class="discussion">
2789
- <p>Returns The tags associated with the content. Can be an <code>Array</code> or an <code>HashWithIndifferentAccess</code>, if multiple tags set are specified for multiple locales.</p>
3204
+ <p>Returns The tags associated with the content. Can be an <code>Array</code> or an <code>HashWithIndifferentAccess</code>, if multiple tags set
3205
+ are specified for multiple locales.</p>
2790
3206
 
2791
3207
 
2792
3208
  </div>
@@ -2804,7 +3220,8 @@
2804
3220
 
2805
3221
 
2806
3222
  &mdash;
2807
- <div class='inline'><p>The tags associated with the content. Can be an <code>Array</code> or an <code>HashWithIndifferentAccess</code>, if multiple tags set are specified for multiple locales.</p>
3223
+ <div class='inline'><p>The tags associated with the content. Can be an <code>Array</code> or an <code>HashWithIndifferentAccess</code>, if multiple tags set
3224
+ are specified for multiple locales.</p>
2808
3225
  </div>
2809
3226
 
2810
3227
  </li>
@@ -2817,16 +3234,6 @@
2817
3234
  <pre class="lines">
2818
3235
 
2819
3236
 
2820
- 107
2821
- 108
2822
- 109
2823
- 110
2824
- 111
2825
- 112
2826
- 113
2827
- 114
2828
- 115
2829
- 116
2830
3237
  117
2831
3238
  118
2832
3239
  119
@@ -3007,10 +3414,59 @@
3007
3414
  294
3008
3415
  295
3009
3416
  296
3010
- 297</pre>
3417
+ 297
3418
+ 298
3419
+ 299
3420
+ 300
3421
+ 301
3422
+ 302
3423
+ 303
3424
+ 304
3425
+ 305
3426
+ 306
3427
+ 307
3428
+ 308
3429
+ 309
3430
+ 310
3431
+ 311
3432
+ 312
3433
+ 313
3434
+ 314
3435
+ 315
3436
+ 316
3437
+ 317
3438
+ 318
3439
+ 319
3440
+ 320
3441
+ 321
3442
+ 322
3443
+ 323
3444
+ 324
3445
+ 325
3446
+ 326
3447
+ 327
3448
+ 328
3449
+ 329
3450
+ 330
3451
+ 331
3452
+ 332
3453
+ 333
3454
+ 334
3455
+ 335
3456
+ 336
3457
+ 337
3458
+ 338
3459
+ 339
3460
+ 340
3461
+ 341
3462
+ 342
3463
+ 343
3464
+ 344
3465
+ 345
3466
+ 346</pre>
3011
3467
  </td>
3012
3468
  <td>
3013
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
3469
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
3014
3470
 
3015
3471
  <span class='kw'>class</span> <span class='const'>Content</span>
3016
3472
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -3042,9 +3498,10 @@
3042
3498
 
3043
3499
  <span class='comment'># Sets the `title` attribute.
3044
3500
  </span> <span class='comment'>#
3045
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3046
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3047
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3501
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
3502
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
3503
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
3504
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3048
3505
  <span class='kw'>end</span>
3049
3506
 
3050
3507
  <span class='comment'># Sets the `body` attribute.
@@ -3056,33 +3513,35 @@
3056
3513
 
3057
3514
  <span class='comment'># Sets the `tags` attribute.
3058
3515
  </span> <span class='comment'>#
3059
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3060
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3061
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3062
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
3516
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
3517
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
3518
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
3519
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
3520
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
3063
3521
  <span class='kw'>else</span>
3064
- <span class='id identifier rubyid_value'>value</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>
3522
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
3065
3523
  <span class='kw'>end</span>
3066
3524
  <span class='kw'>end</span>
3067
3525
 
3068
3526
  <span class='comment'># Sets the `more` attribute.
3069
3527
  </span> <span class='comment'>#
3070
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3071
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3072
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3528
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
3529
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
3530
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
3531
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3073
3532
  <span class='kw'>end</span>
3074
3533
 
3075
3534
  <span class='comment'># Sets the `author` attribute.
3076
3535
  </span> <span class='comment'>#
3077
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
3078
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3079
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
3080
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
3081
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3082
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3083
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
3536
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
3537
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
3538
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
3539
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
3540
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
3541
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3542
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
3084
3543
  <span class='kw'>else</span>
3085
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
3544
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
3086
3545
  <span class='kw'>end</span>
3087
3546
  <span class='kw'>end</span>
3088
3547
 
@@ -3110,18 +3569,32 @@
3110
3569
 
3111
3570
  <span class='comment'># Sets the `metadata` attribute.
3112
3571
  </span> <span class='comment'>#
3113
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
3114
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3115
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3116
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3572
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
3573
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
3574
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
3575
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3117
3576
  <span class='kw'>else</span>
3118
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
3577
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
3119
3578
  <span class='kw'>end</span>
3120
3579
  <span class='kw'>end</span>
3121
3580
 
3581
+ <span class='comment'># Returns the content as an Hash.
3582
+ </span> <span class='comment'>#
3583
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
3584
+ </span> <span class='comment'># The only supported value are:
3585
+ </span> <span class='comment'>#
3586
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
3587
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
3588
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
3589
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
3590
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
3591
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
3592
+ <span class='kw'>end</span>
3593
+
3122
3594
  <span class='comment'># Validates locales for attribute retrieval.
3123
3595
  </span> <span class='comment'>#
3124
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
3596
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
3597
+ </span> <span class='comment'># used.
3125
3598
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
3126
3599
  </span> <span class='comment'># @return [Array] The validated list of locales.
3127
3600
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -3186,22 +3659,44 @@
3186
3659
  <span class='comment'># Extracts a date and time from a value.
3187
3660
  </span> <span class='comment'>#
3188
3661
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3189
- </span> <span class='comment'># @return [DateTime] The extract values.
3662
+ </span> <span class='comment'># @return [DateTime] The extracted value.
3190
3663
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3191
3664
  <span class='kw'>begin</span>
3192
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
3193
- <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_to_datetime'>to_datetime</span>
3194
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
3195
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
3196
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
3197
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
3198
- <span class='kw'>end</span>
3199
-
3665
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
3200
3666
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
3201
3667
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
3202
3668
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
3203
3669
  <span class='kw'>end</span>
3204
3670
  <span class='kw'>end</span>
3671
+
3672
+ <span class='comment'># Parse a datetime
3673
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3674
+ </span> <span class='comment'># @return [DateTime] The extracted value.
3675
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3676
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
3677
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
3678
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
3679
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
3680
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
3681
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
3682
+ <span class='kw'>end</span>
3683
+ <span class='kw'>end</span>
3684
+
3685
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
3686
+ </span> <span class='comment'>#
3687
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
3688
+ </span> <span class='comment'># @return [Array] The list of tags.
3689
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3690
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
3691
+ <span class='kw'>end</span>
3692
+
3693
+ <span class='comment'># Check if value is an Hash.
3694
+ </span> <span class='comment'>#
3695
+ </span> <span class='comment'># @param value [Object] The object to check.
3696
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
3697
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3698
+ <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'>Hash</span><span class='rparen'>)</span>
3699
+ <span class='kw'>end</span>
3205
3700
  <span class='kw'>end</span></pre>
3206
3701
  </td>
3207
3702
  </tr>
@@ -3221,7 +3716,8 @@
3221
3716
 
3222
3717
  </h3><div class="docstring">
3223
3718
  <div class="discussion">
3224
- <p>Returns The content’s title. Can be a <code>String</code> or an <code>HashWithIndifferentAccess</code>, if multiple title are specified for multiple locales.</p>
3719
+ <p>Returns The content’s title. Can be a <code>String</code> or an <code>HashWithIndifferentAccess</code>, if multiple title are specified for
3720
+ multiple locales.</p>
3225
3721
 
3226
3722
 
3227
3723
  </div>
@@ -3239,7 +3735,8 @@
3239
3735
 
3240
3736
 
3241
3737
  &mdash;
3242
- <div class='inline'><p>The content’s title. Can be a <code>String</code> or an <code>HashWithIndifferentAccess</code>, if multiple title are specified for multiple locales.</p>
3738
+ <div class='inline'><p>The content’s title. Can be a <code>String</code> or an <code>HashWithIndifferentAccess</code>, if multiple title are specified for
3739
+ multiple locales.</p>
3243
3740
  </div>
3244
3741
 
3245
3742
  </li>
@@ -3252,16 +3749,6 @@
3252
3749
  <pre class="lines">
3253
3750
 
3254
3751
 
3255
- 107
3256
- 108
3257
- 109
3258
- 110
3259
- 111
3260
- 112
3261
- 113
3262
- 114
3263
- 115
3264
- 116
3265
3752
  117
3266
3753
  118
3267
3754
  119
@@ -3442,10 +3929,59 @@
3442
3929
  294
3443
3930
  295
3444
3931
  296
3445
- 297</pre>
3932
+ 297
3933
+ 298
3934
+ 299
3935
+ 300
3936
+ 301
3937
+ 302
3938
+ 303
3939
+ 304
3940
+ 305
3941
+ 306
3942
+ 307
3943
+ 308
3944
+ 309
3945
+ 310
3946
+ 311
3947
+ 312
3948
+ 313
3949
+ 314
3950
+ 315
3951
+ 316
3952
+ 317
3953
+ 318
3954
+ 319
3955
+ 320
3956
+ 321
3957
+ 322
3958
+ 323
3959
+ 324
3960
+ 325
3961
+ 326
3962
+ 327
3963
+ 328
3964
+ 329
3965
+ 330
3966
+ 331
3967
+ 332
3968
+ 333
3969
+ 334
3970
+ 335
3971
+ 336
3972
+ 337
3973
+ 338
3974
+ 339
3975
+ 340
3976
+ 341
3977
+ 342
3978
+ 343
3979
+ 344
3980
+ 345
3981
+ 346</pre>
3446
3982
  </td>
3447
3983
  <td>
3448
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
3984
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
3449
3985
 
3450
3986
  <span class='kw'>class</span> <span class='const'>Content</span>
3451
3987
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -3477,9 +4013,10 @@
3477
4013
 
3478
4014
  <span class='comment'># Sets the `title` attribute.
3479
4015
  </span> <span class='comment'>#
3480
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3481
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3482
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4016
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
4017
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4018
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
4019
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3483
4020
  <span class='kw'>end</span>
3484
4021
 
3485
4022
  <span class='comment'># Sets the `body` attribute.
@@ -3491,33 +4028,35 @@
3491
4028
 
3492
4029
  <span class='comment'># Sets the `tags` attribute.
3493
4030
  </span> <span class='comment'>#
3494
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3495
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3496
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3497
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
4031
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
4032
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
4033
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
4034
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
4035
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
3498
4036
  <span class='kw'>else</span>
3499
- <span class='id identifier rubyid_value'>value</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>
4037
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
3500
4038
  <span class='kw'>end</span>
3501
4039
  <span class='kw'>end</span>
3502
4040
 
3503
4041
  <span class='comment'># Sets the `more` attribute.
3504
4042
  </span> <span class='comment'>#
3505
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3506
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3507
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4043
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
4044
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4045
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
4046
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3508
4047
  <span class='kw'>end</span>
3509
4048
 
3510
4049
  <span class='comment'># Sets the `author` attribute.
3511
4050
  </span> <span class='comment'>#
3512
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
3513
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3514
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
3515
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
3516
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3517
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3518
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
4051
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
4052
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
4053
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
4054
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
4055
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
4056
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
4057
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
3519
4058
  <span class='kw'>else</span>
3520
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
4059
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
3521
4060
  <span class='kw'>end</span>
3522
4061
  <span class='kw'>end</span>
3523
4062
 
@@ -3545,18 +4084,32 @@
3545
4084
 
3546
4085
  <span class='comment'># Sets the `metadata` attribute.
3547
4086
  </span> <span class='comment'>#
3548
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
3549
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3550
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3551
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
4087
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
4088
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
4089
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
4090
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3552
4091
  <span class='kw'>else</span>
3553
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
4092
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
3554
4093
  <span class='kw'>end</span>
3555
4094
  <span class='kw'>end</span>
3556
4095
 
4096
+ <span class='comment'># Returns the content as an Hash.
4097
+ </span> <span class='comment'>#
4098
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
4099
+ </span> <span class='comment'># The only supported value are:
4100
+ </span> <span class='comment'>#
4101
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
4102
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
4103
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
4104
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
4105
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
4106
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
4107
+ <span class='kw'>end</span>
4108
+
3557
4109
  <span class='comment'># Validates locales for attribute retrieval.
3558
4110
  </span> <span class='comment'>#
3559
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
4111
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
4112
+ </span> <span class='comment'># used.
3560
4113
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
3561
4114
  </span> <span class='comment'># @return [Array] The validated list of locales.
3562
4115
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -3621,22 +4174,44 @@
3621
4174
  <span class='comment'># Extracts a date and time from a value.
3622
4175
  </span> <span class='comment'>#
3623
4176
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3624
- </span> <span class='comment'># @return [DateTime] The extract values.
4177
+ </span> <span class='comment'># @return [DateTime] The extracted value.
3625
4178
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3626
4179
  <span class='kw'>begin</span>
3627
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
3628
- <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_to_datetime'>to_datetime</span>
3629
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
3630
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
3631
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
3632
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
3633
- <span class='kw'>end</span>
3634
-
4180
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
3635
4181
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
3636
4182
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
3637
4183
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
3638
4184
  <span class='kw'>end</span>
3639
4185
  <span class='kw'>end</span>
4186
+
4187
+ <span class='comment'># Parse a datetime
4188
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4189
+ </span> <span class='comment'># @return [DateTime] The extracted value.
4190
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4191
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
4192
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
4193
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
4194
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
4195
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
4196
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
4197
+ <span class='kw'>end</span>
4198
+ <span class='kw'>end</span>
4199
+
4200
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
4201
+ </span> <span class='comment'>#
4202
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
4203
+ </span> <span class='comment'># @return [Array] The list of tags.
4204
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4205
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
4206
+ <span class='kw'>end</span>
4207
+
4208
+ <span class='comment'># Check if value is an Hash.
4209
+ </span> <span class='comment'>#
4210
+ </span> <span class='comment'># @param value [Object] The object to check.
4211
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
4212
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4213
+ <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'>Hash</span><span class='rparen'>)</span>
4214
+ <span class='kw'>end</span>
3640
4215
  <span class='kw'>end</span></pre>
3641
4216
  </td>
3642
4217
  </tr>
@@ -3687,16 +4262,6 @@
3687
4262
  <pre class="lines">
3688
4263
 
3689
4264
 
3690
- 107
3691
- 108
3692
- 109
3693
- 110
3694
- 111
3695
- 112
3696
- 113
3697
- 114
3698
- 115
3699
- 116
3700
4265
  117
3701
4266
  118
3702
4267
  119
@@ -3877,10 +4442,59 @@
3877
4442
  294
3878
4443
  295
3879
4444
  296
3880
- 297</pre>
4445
+ 297
4446
+ 298
4447
+ 299
4448
+ 300
4449
+ 301
4450
+ 302
4451
+ 303
4452
+ 304
4453
+ 305
4454
+ 306
4455
+ 307
4456
+ 308
4457
+ 309
4458
+ 310
4459
+ 311
4460
+ 312
4461
+ 313
4462
+ 314
4463
+ 315
4464
+ 316
4465
+ 317
4466
+ 318
4467
+ 319
4468
+ 320
4469
+ 321
4470
+ 322
4471
+ 323
4472
+ 324
4473
+ 325
4474
+ 326
4475
+ 327
4476
+ 328
4477
+ 329
4478
+ 330
4479
+ 331
4480
+ 332
4481
+ 333
4482
+ 334
4483
+ 335
4484
+ 336
4485
+ 337
4486
+ 338
4487
+ 339
4488
+ 340
4489
+ 341
4490
+ 342
4491
+ 343
4492
+ 344
4493
+ 345
4494
+ 346</pre>
3881
4495
  </td>
3882
4496
  <td>
3883
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
4497
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
3884
4498
 
3885
4499
  <span class='kw'>class</span> <span class='const'>Content</span>
3886
4500
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -3912,9 +4526,10 @@
3912
4526
 
3913
4527
  <span class='comment'># Sets the `title` attribute.
3914
4528
  </span> <span class='comment'>#
3915
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3916
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3917
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4529
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
4530
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4531
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
4532
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3918
4533
  <span class='kw'>end</span>
3919
4534
 
3920
4535
  <span class='comment'># Sets the `body` attribute.
@@ -3926,33 +4541,35 @@
3926
4541
 
3927
4542
  <span class='comment'># Sets the `tags` attribute.
3928
4543
  </span> <span class='comment'>#
3929
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3930
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3931
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3932
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
4544
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
4545
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
4546
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
4547
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
4548
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
3933
4549
  <span class='kw'>else</span>
3934
- <span class='id identifier rubyid_value'>value</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>
4550
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
3935
4551
  <span class='kw'>end</span>
3936
4552
  <span class='kw'>end</span>
3937
4553
 
3938
4554
  <span class='comment'># Sets the `more` attribute.
3939
4555
  </span> <span class='comment'>#
3940
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
3941
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3942
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4556
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
4557
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4558
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
4559
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3943
4560
  <span class='kw'>end</span>
3944
4561
 
3945
4562
  <span class='comment'># Sets the `author` attribute.
3946
4563
  </span> <span class='comment'>#
3947
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
3948
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3949
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
3950
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
3951
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3952
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3953
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
4564
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
4565
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
4566
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
4567
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
4568
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
4569
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
4570
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
3954
4571
  <span class='kw'>else</span>
3955
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
4572
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
3956
4573
  <span class='kw'>end</span>
3957
4574
  <span class='kw'>end</span>
3958
4575
 
@@ -3980,18 +4597,32 @@
3980
4597
 
3981
4598
  <span class='comment'># Sets the `metadata` attribute.
3982
4599
  </span> <span class='comment'>#
3983
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
3984
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3985
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
3986
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
4600
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
4601
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
4602
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
4603
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
3987
4604
  <span class='kw'>else</span>
3988
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
4605
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
3989
4606
  <span class='kw'>end</span>
3990
4607
  <span class='kw'>end</span>
3991
4608
 
4609
+ <span class='comment'># Returns the content as an Hash.
4610
+ </span> <span class='comment'>#
4611
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
4612
+ </span> <span class='comment'># The only supported value are:
4613
+ </span> <span class='comment'>#
4614
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
4615
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
4616
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
4617
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
4618
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
4619
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
4620
+ <span class='kw'>end</span>
4621
+
3992
4622
  <span class='comment'># Validates locales for attribute retrieval.
3993
4623
  </span> <span class='comment'>#
3994
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
4624
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
4625
+ </span> <span class='comment'># used.
3995
4626
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
3996
4627
  </span> <span class='comment'># @return [Array] The validated list of locales.
3997
4628
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -4056,22 +4687,44 @@
4056
4687
  <span class='comment'># Extracts a date and time from a value.
4057
4688
  </span> <span class='comment'>#
4058
4689
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4059
- </span> <span class='comment'># @return [DateTime] The extract values.
4690
+ </span> <span class='comment'># @return [DateTime] The extracted value.
4060
4691
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4061
4692
  <span class='kw'>begin</span>
4062
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
4063
- <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_to_datetime'>to_datetime</span>
4064
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
4065
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
4066
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
4067
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
4068
- <span class='kw'>end</span>
4069
-
4693
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
4070
4694
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
4071
4695
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
4072
4696
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
4073
4697
  <span class='kw'>end</span>
4074
4698
  <span class='kw'>end</span>
4699
+
4700
+ <span class='comment'># Parse a datetime
4701
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4702
+ </span> <span class='comment'># @return [DateTime] The extracted value.
4703
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4704
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
4705
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
4706
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
4707
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
4708
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
4709
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
4710
+ <span class='kw'>end</span>
4711
+ <span class='kw'>end</span>
4712
+
4713
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
4714
+ </span> <span class='comment'>#
4715
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
4716
+ </span> <span class='comment'># @return [Array] The list of tags.
4717
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4718
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
4719
+ <span class='kw'>end</span>
4720
+
4721
+ <span class='comment'># Check if value is an Hash.
4722
+ </span> <span class='comment'>#
4723
+ </span> <span class='comment'># @param value [Object] The object to check.
4724
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
4725
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4726
+ <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'>Hash</span><span class='rparen'>)</span>
4727
+ <span class='kw'>end</span>
4075
4728
  <span class='kw'>end</span></pre>
4076
4729
  </td>
4077
4730
  </tr>
@@ -4122,16 +4775,6 @@
4122
4775
  <pre class="lines">
4123
4776
 
4124
4777
 
4125
- 107
4126
- 108
4127
- 109
4128
- 110
4129
- 111
4130
- 112
4131
- 113
4132
- 114
4133
- 115
4134
- 116
4135
4778
  117
4136
4779
  118
4137
4780
  119
@@ -4312,10 +4955,59 @@
4312
4955
  294
4313
4956
  295
4314
4957
  296
4315
- 297</pre>
4958
+ 297
4959
+ 298
4960
+ 299
4961
+ 300
4962
+ 301
4963
+ 302
4964
+ 303
4965
+ 304
4966
+ 305
4967
+ 306
4968
+ 307
4969
+ 308
4970
+ 309
4971
+ 310
4972
+ 311
4973
+ 312
4974
+ 313
4975
+ 314
4976
+ 315
4977
+ 316
4978
+ 317
4979
+ 318
4980
+ 319
4981
+ 320
4982
+ 321
4983
+ 322
4984
+ 323
4985
+ 324
4986
+ 325
4987
+ 326
4988
+ 327
4989
+ 328
4990
+ 329
4991
+ 330
4992
+ 331
4993
+ 332
4994
+ 333
4995
+ 334
4996
+ 335
4997
+ 336
4998
+ 337
4999
+ 338
5000
+ 339
5001
+ 340
5002
+ 341
5003
+ 342
5004
+ 343
5005
+ 344
5006
+ 345
5007
+ 346</pre>
4316
5008
  </td>
4317
5009
  <td>
4318
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 107</span>
5010
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 117</span>
4319
5011
 
4320
5012
  <span class='kw'>class</span> <span class='const'>Content</span>
4321
5013
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>ContentPublicInterface</span>
@@ -4347,9 +5039,10 @@
4347
5039
 
4348
5040
  <span class='comment'># Sets the `title` attribute.
4349
5041
  </span> <span class='comment'>#
4350
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
4351
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4352
- <span class='ivar'>@title</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
5042
+ </span> <span class='comment'># @param new_title [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
5043
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
5044
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_title='>title=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span>
5045
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_title'>new_title</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_title'>new_title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4353
5046
  <span class='kw'>end</span>
4354
5047
 
4355
5048
  <span class='comment'># Sets the `body` attribute.
@@ -4361,33 +5054,35 @@
4361
5054
 
4362
5055
  <span class='comment'># Sets the `tags` attribute.
4363
5056
  </span> <span class='comment'>#
4364
- </span> <span class='comment'># @param value [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
4365
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4366
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
4367
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</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> <span class='rbrace'>}</span>
5057
+ </span> <span class='comment'># @param new_tags [Array|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
5058
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
5059
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_tags='>tags=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
5060
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='kw'>then</span>
5061
+ <span class='id identifier rubyid_new_tags'>new_tags</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
4368
5062
  <span class='kw'>else</span>
4369
- <span class='id identifier rubyid_value'>value</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>
5063
+ <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span>
4370
5064
  <span class='kw'>end</span>
4371
5065
  <span class='kw'>end</span>
4372
5066
 
4373
5067
  <span class='comment'># Sets the `more` attribute.
4374
5068
  </span> <span class='comment'>#
4375
- </span> <span class='comment'># @param value [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas. A empty or &quot;*&quot; will be the default value.
4376
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4377
- <span class='ivar'>@more</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
5069
+ </span> <span class='comment'># @param new_more [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
5070
+ </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
5071
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_more='>more=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span>
5072
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_more'>new_more</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_more'>new_more</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4378
5073
  <span class='kw'>end</span>
4379
5074
 
4380
5075
  <span class='comment'># Sets the `author` attribute.
4381
5076
  </span> <span class='comment'>#
4382
- </span> <span class='comment'># @param value [Author|Hash|Object] The new value for the attribute.
4383
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4384
- <span class='kw'>if</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'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
4385
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
4386
- <span class='kw'>elsif</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
4387
- <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_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
4388
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>email</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>image</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>metadata</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uid</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
5077
+ </span> <span class='comment'># @param new_author [Author|Hash|Object|NilClass] The new value for the attribute.
5078
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_author='>author=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
5079
+ <span class='kw'>if</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='rparen'>)</span> <span class='kw'>then</span>
5080
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span>
5081
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span> <span class='kw'>then</span>
5082
+ <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
5083
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
4389
5084
  <span class='kw'>else</span>
4390
- <span class='ivar'>@author</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
5085
+ <span class='ivar'>@author</span> <span class='op'>=</span> <span class='id identifier rubyid_new_author'>new_author</span> <span class='op'>?</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Author</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
4391
5086
  <span class='kw'>end</span>
4392
5087
  <span class='kw'>end</span>
4393
5088
 
@@ -4415,18 +5110,32 @@
4415
5110
 
4416
5111
  <span class='comment'># Sets the `metadata` attribute.
4417
5112
  </span> <span class='comment'>#
4418
- </span> <span class='comment'># @param value [Hash] The new value for the attribute.
4419
- </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4420
- <span class='kw'>if</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'>Hash</span><span class='rparen'>)</span> <span class='kw'>then</span>
4421
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
5113
+ </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
5114
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_metadata='>metadata=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span>
5115
+ <span class='kw'>if</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</span> <span class='kw'>then</span>
5116
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='symbol'>:indifferent</span><span class='rparen'>)</span>
4422
5117
  <span class='kw'>else</span>
4423
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='rparen'>)</span>
5118
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>raw:</span> <span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rbrace'>}</span><span class='rparen'>)</span>
4424
5119
  <span class='kw'>end</span>
4425
5120
  <span class='kw'>end</span>
4426
5121
 
5122
+ <span class='comment'># Returns the content as an Hash.
5123
+ </span> <span class='comment'>#
5124
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
5125
+ </span> <span class='comment'># The only supported value are:
5126
+ </span> <span class='comment'>#
5127
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
5128
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
5129
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
5130
+ </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_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
5131
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
5132
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
5133
+ <span class='kw'>end</span>
5134
+
4427
5135
  <span class='comment'># Validates locales for attribute retrieval.
4428
5136
  </span> <span class='comment'>#
4429
- </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be used.
5137
+ </span> <span class='comment'># @param locales [Array] A list of desired locales for an attribute. Can include `*` to match all. If none are specified, the default mbrao locale will be
5138
+ </span> <span class='comment'># used.
4430
5139
  </span> <span class='comment'># @param content [Content|nil] An optional content to check for availability
4431
5140
  </span> <span class='comment'># @return [Array] The validated list of locales.
4432
5141
  </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
@@ -4491,22 +5200,44 @@
4491
5200
  <span class='comment'># Extracts a date and time from a value.
4492
5201
  </span> <span class='comment'>#
4493
5202
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4494
- </span> <span class='comment'># @return [DateTime] The extract values.
5203
+ </span> <span class='comment'># @return [DateTime] The extracted value.
4495
5204
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_extract_datetime'>extract_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4496
5205
  <span class='kw'>begin</span>
4497
- <span class='kw'>if</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'>Date</span><span class='rparen'>)</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'>Time</span><span class='rparen'>)</span> <span class='kw'>then</span>
4498
- <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_to_datetime'>to_datetime</span>
4499
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='kw'>then</span>
4500
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
4501
- <span class='kw'>elsif</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</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'>DateTime</span><span class='rparen'>)</span> <span class='kw'>then</span>
4502
- <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
4503
- <span class='kw'>end</span>
4504
-
5206
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span>
4505
5207
  <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_utc'>utc</span> <span class='op'>:</span> <span class='kw'>nil</span>
4506
5208
  <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
4507
5209
  <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'>InvalidDate</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
4508
5210
  <span class='kw'>end</span>
4509
5211
  <span class='kw'>end</span>
5212
+
5213
+ <span class='comment'># Parse a datetime
5214
+ </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
5215
+ </span> <span class='comment'># @return [DateTime] The extracted value.
5216
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5217
+ <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
5218
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
5219
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
5220
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
5221
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
5222
+ <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
5223
+ <span class='kw'>end</span>
5224
+ <span class='kw'>end</span>
5225
+
5226
+ <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
5227
+ </span> <span class='comment'>#
5228
+ </span> <span class='comment'># @param value [String|Array] The string or array to parse.
5229
+ </span> <span class='comment'># @return [Array] The list of tags.
5230
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_tags'>parse_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5231
+ <span class='id identifier rubyid_value'>value</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='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
5232
+ <span class='kw'>end</span>
5233
+
5234
+ <span class='comment'># Check if value is an Hash.
5235
+ </span> <span class='comment'>#
5236
+ </span> <span class='comment'># @param value [Object] The object to check.
5237
+ </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
5238
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_is_hash?'>is_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5239
+ <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'>Hash</span><span class='rparen'>)</span>
5240
+ <span class='kw'>end</span>
4510
5241
  <span class='kw'>end</span></pre>
4511
5242
  </td>
4512
5243
  </tr>
@@ -4596,15 +5327,15 @@
4596
5327
  <pre class="lines">
4597
5328
 
4598
5329
 
4599
- 231
4600
- 232
4601
- 233
4602
- 234
4603
- 235
4604
- 236</pre>
5330
+ 258
5331
+ 259
5332
+ 260
5333
+ 261
5334
+ 262
5335
+ 263</pre>
4605
5336
  </td>
4606
5337
  <td>
4607
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 231</span>
5338
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 258</span>
4608
5339
 
4609
5340
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='comma'>,</span> <span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
4610
5341
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Content</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
@@ -4647,7 +5378,8 @@
4647
5378
 
4648
5379
 
4649
5380
  &mdash;
4650
- <div class='inline'><p>A list of desired locales for an attribute. Can include <code>*</code> to match all. If none are specified, the default mbrao locale will be used.</p>
5381
+ <div class='inline'><p>A list of desired locales for an attribute. Can include <code>*</code> to match all. If none are specified, the default mbrao locale will be
5382
+ used.</p>
4651
5383
  </div>
4652
5384
 
4653
5385
  </li>
@@ -4708,15 +5440,15 @@
4708
5440
  <pre class="lines">
4709
5441
 
4710
5442
 
4711
- 219
4712
- 220
4713
- 221
4714
- 222
4715
- 223
4716
- 224</pre>
5443
+ 246
5444
+ 247
5445
+ 248
5446
+ 249
5447
+ 250
5448
+ 251</pre>
4717
5449
  </td>
4718
5450
  <td>
4719
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 219</span>
5451
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 246</span>
4720
5452
 
4721
5453
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
4722
5454
  <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_locales'>locales</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='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='id identifier rubyid_l'>l</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='rbrace'>}</span>
@@ -4727,6 +5459,98 @@
4727
5459
  </td>
4728
5460
  </tr>
4729
5461
  </table>
5462
+ </div>
5463
+
5464
+ </div>
5465
+
5466
+ <div id="instance_method_details" class="method_details_list">
5467
+ <h2>Instance Method Details</h2>
5468
+
5469
+
5470
+ <div class="method_details first">
5471
+ <h3 class="signature first" id="as_json-instance_method">
5472
+
5473
+ - (<tt>Hash</tt>) <strong>as_json</strong>(options = {})
5474
+
5475
+
5476
+
5477
+
5478
+
5479
+ </h3><div class="docstring">
5480
+ <div class="discussion">
5481
+ <p>Returns the content as an Hash.</p>
5482
+
5483
+
5484
+ </div>
5485
+ </div>
5486
+ <div class="tags">
5487
+ <p class="tag_title">Parameters:</p>
5488
+ <ul class="param">
5489
+
5490
+ <li>
5491
+
5492
+ <span class='name'>options</span>
5493
+
5494
+
5495
+ <span class='type'>(<tt>Hash</tt>)</span>
5496
+
5497
+
5498
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
5499
+
5500
+
5501
+ &mdash;
5502
+ <div class='inline'><p>Options to modify behavior of the serialization.
5503
+ The only supported value are:</p>
5504
+
5505
+ <ul>
5506
+ <li><code>:exclude</code>, an array of attributes to skip.</li>
5507
+ <li><code>:exclude_empty</code>, if to exclude nil values. Default is <code>false</code>.</li>
5508
+ </ul>
5509
+ </div>
5510
+
5511
+ </li>
5512
+
5513
+ </ul>
5514
+
5515
+ <p class="tag_title">Returns:</p>
5516
+ <ul class="return">
5517
+
5518
+ <li>
5519
+
5520
+
5521
+ <span class='type'>(<tt>Hash</tt>)</span>
5522
+
5523
+
5524
+
5525
+ &mdash;
5526
+ <div class='inline'><p>An hash with all attributes.</p>
5527
+ </div>
5528
+
5529
+ </li>
5530
+
5531
+ </ul>
5532
+
5533
+ </div><table class="source_code">
5534
+ <tr>
5535
+ <td>
5536
+ <pre class="lines">
5537
+
5538
+
5539
+ 235
5540
+ 236
5541
+ 237
5542
+ 238</pre>
5543
+ </td>
5544
+ <td>
5545
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 235</span>
5546
+
5547
+ <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</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>
5548
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
5549
+ <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='kw'>self</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='rparen'>)</span>
5550
+ <span class='kw'>end</span></pre>
5551
+ </td>
5552
+ </tr>
5553
+ </table>
4730
5554
  </div>
4731
5555
 
4732
5556
  </div>
@@ -4734,7 +5558,7 @@
4734
5558
  </div>
4735
5559
 
4736
5560
  <div id="footer">
4737
- Generated on Sat Nov 23 13:44:02 2013 by
5561
+ Generated on Sun Nov 24 14:07:04 2013 by
4738
5562
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
4739
5563
  0.8.7.3 (ruby-2.0.0).
4740
5564
  </div>