mbrao 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -4
  3. data/.rubocop.yml +51 -3
  4. data/.travis-gemfile +5 -5
  5. data/.travis.yml +5 -3
  6. data/CHANGELOG.md +5 -0
  7. data/Gemfile +10 -9
  8. data/README.md +1 -2
  9. data/Rakefile +22 -6
  10. data/doc/ActionView.html +3 -3
  11. data/doc/ActionView/Template.html +3 -3
  12. data/doc/ActionView/Template/Handlers.html +3 -3
  13. data/doc/ActionView/Template/Handlers/MbraoTemplate.html +3 -3
  14. data/doc/HTML.html +3 -3
  15. data/doc/HTML/Pipeline.html +3 -3
  16. data/doc/HTML/Pipeline/KramdownFilter.html +3 -3
  17. data/doc/Mbrao.html +5 -5
  18. data/doc/Mbrao/Author.html +10 -10
  19. data/doc/Mbrao/Content.html +825 -844
  20. data/doc/Mbrao/ContentInterface.html +5 -5
  21. data/doc/Mbrao/ContentInterface/ClassMethods.html +4 -4
  22. data/doc/Mbrao/Exceptions.html +3 -3
  23. data/doc/Mbrao/Exceptions/InvalidDate.html +3 -3
  24. data/doc/Mbrao/Exceptions/InvalidMetadata.html +3 -3
  25. data/doc/Mbrao/Exceptions/Parsing.html +3 -3
  26. data/doc/Mbrao/Exceptions/Rendering.html +3 -3
  27. data/doc/Mbrao/Exceptions/UnavailableLocalization.html +3 -3
  28. data/doc/Mbrao/Exceptions/Unimplemented.html +3 -3
  29. data/doc/Mbrao/Exceptions/UnknownEngine.html +3 -3
  30. data/doc/Mbrao/Parser.html +3 -3
  31. data/doc/Mbrao/ParserInterface.html +3 -3
  32. data/doc/Mbrao/ParserInterface/ClassMethods.html +35 -95
  33. data/doc/Mbrao/ParserValidations.html +3 -3
  34. data/doc/Mbrao/ParserValidations/ClassMethods.html +3 -3
  35. data/doc/Mbrao/ParsingEngines.html +3 -3
  36. data/doc/Mbrao/ParsingEngines/Base.html +3 -3
  37. data/doc/Mbrao/ParsingEngines/PlainText.html +11 -17
  38. data/doc/Mbrao/RenderingEngines.html +3 -3
  39. data/doc/Mbrao/RenderingEngines/Base.html +3 -3
  40. data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +24 -92
  41. data/doc/Mbrao/Version.html +4 -4
  42. data/doc/_index.html +8 -8
  43. data/doc/class_list.html +5 -1
  44. data/doc/file.README.html +5 -6
  45. data/doc/file_list.html +5 -1
  46. data/doc/frames.html +1 -1
  47. data/doc/index.html +5 -6
  48. data/doc/js/full_list.js +4 -1
  49. data/doc/method_list.html +75 -53
  50. data/doc/top-level-namespace.html +3 -3
  51. data/lib/mbrao/author.rb +1 -1
  52. data/lib/mbrao/content.rb +47 -65
  53. data/lib/mbrao/content_interface.rb +5 -17
  54. data/lib/mbrao/parser.rb +4 -10
  55. data/lib/mbrao/parser_interface.rb +9 -19
  56. data/lib/mbrao/parsing_engines/plain_text.rb +22 -58
  57. data/lib/mbrao/rendering_engines/html_pipeline.rb +9 -26
  58. data/lib/mbrao/version.rb +1 -1
  59. data/mbrao.gemspec +9 -9
  60. data/spec/mbrao/content_spec.rb +4 -4
  61. data/spec/mbrao/integrations/rails_spec.rb +4 -4
  62. data/spec/mbrao/parser_spec.rb +15 -15
  63. data/spec/spec_helper.rb +19 -5
  64. metadata +17 -19
  65. data/spec/coverage_helper.rb +0 -20
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Class: Mbrao::Content
8
8
 
9
- &mdash; Documentation by YARD 0.8.7.4
9
+ &mdash; Documentation by YARD 0.8.7.6
10
10
 
11
11
  </title>
12
12
 
@@ -421,6 +421,84 @@
421
421
 
422
422
 
423
423
 
424
+ <h2>
425
+ Class Method Summary
426
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
427
+ </h2>
428
+
429
+ <ul class="summary">
430
+
431
+ <li class="public ">
432
+ <span class="summary_signature">
433
+
434
+ <a href="#assign_metadata-class_method" title="assign_metadata (class method)">+ (Content) <strong>assign_metadata</strong>(content, metadata) </a>
435
+
436
+
437
+
438
+ </span>
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+ <span class="summary_desc"><div class='inline'><p>Assigns metadata to a content.</p>
449
+ </div></span>
450
+
451
+ </li>
452
+
453
+
454
+ <li class="public ">
455
+ <span class="summary_signature">
456
+
457
+ <a href="#extract_locales-class_method" title="extract_locales (class method)">+ (Array) <strong>extract_locales</strong>(locales) </a>
458
+
459
+
460
+
461
+ </span>
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+ <span class="summary_desc"><div class='inline'><p>Extracts locales from metadata.</p>
472
+ </div></span>
473
+
474
+ </li>
475
+
476
+
477
+ <li class="public ">
478
+ <span class="summary_signature">
479
+
480
+ <a href="#normalize_locales-class_method" title="normalize_locales (class method)">+ (Array) <strong>normalize_locales</strong>(locales) </a>
481
+
482
+
483
+
484
+ </span>
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+ <span class="summary_desc"><div class='inline'><p>Normalizes locales for further usage.</p>
495
+ </div></span>
496
+
497
+ </li>
498
+
499
+
500
+ </ul>
501
+
424
502
  <h2>
425
503
  Instance Method Summary
426
504
  <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
@@ -767,25 +845,7 @@
767
845
  219
768
846
  220
769
847
  221
770
- 222
771
- 223
772
- 224
773
- 225
774
- 226
775
- 227
776
- 228
777
- 229
778
- 230
779
- 231
780
- 232
781
- 233
782
- 234
783
- 235
784
- 236
785
- 237
786
- 238
787
- 239
788
- 240</pre>
848
+ 222</pre>
789
849
  </td>
790
850
  <td>
791
851
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -813,7 +873,7 @@
813
873
  </span> <span class='comment'>#
814
874
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
815
875
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
816
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
876
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
817
877
  <span class='kw'>end</span>
818
878
 
819
879
  <span class='comment'># Sets the `title` attribute.
@@ -821,7 +881,7 @@
821
881
  </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.
822
882
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
823
883
  </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>
824
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
884
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
825
885
  <span class='kw'>end</span>
826
886
 
827
887
  <span class='comment'># Sets the `summary` attribute.
@@ -829,7 +889,7 @@
829
889
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
830
890
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
831
891
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
832
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
892
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
833
893
  <span class='kw'>end</span>
834
894
 
835
895
  <span class='comment'># Sets the `body` attribute.
@@ -844,7 +904,7 @@
844
904
  </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.
845
905
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
846
906
  </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>
847
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
907
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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
908
  <span class='kw'>end</span>
849
909
 
850
910
  <span class='comment'># Sets the `more` attribute.
@@ -852,7 +912,7 @@
852
912
  </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.
853
913
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
854
914
  </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>
855
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
915
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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
916
  <span class='kw'>end</span>
857
917
 
858
918
  <span class='comment'># Sets the `author` attribute.
@@ -862,8 +922,8 @@
862
922
  <span class='ivar'>@author</span> <span class='op'>=</span>
863
923
  <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>
864
924
  <span class='id identifier rubyid_new_author'>new_author</span>
865
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
866
- <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='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='rparen'>)</span>
925
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
926
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
867
927
  <span class='kw'>else</span>
868
928
  <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
929
  <span class='kw'>end</span>
@@ -887,15 +947,44 @@
887
947
  </span> <span class='comment'>#
888
948
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
889
949
  </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>
890
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
950
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
891
951
  <span class='kw'>end</span>
892
952
 
893
- <span class='id identifier rubyid_private'>private</span>
953
+ <span class='comment'># Assigns metadata to a content
954
+ </span> <span class='comment'>#
955
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
956
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
957
+ </span> <span class='comment'># @return [Content] The content with metadata.
958
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
959
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
960
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
961
+ <span class='kw'>end</span>
962
+
963
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
964
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
965
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
966
+ <span class='kw'>end</span>
967
+
968
+ <span class='comment'># Extracts locales from metadata.
969
+ </span> <span class='comment'>#
970
+ </span> <span class='comment'># @param locales [String] The list of locales.
971
+ </span> <span class='comment'># @return [Array] The locales.
972
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
973
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
974
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
975
+ <span class='kw'>end</span>
894
976
 
895
- <span class='comment'># Extracts a date and time from a value.
977
+ <span class='comment'># Normalizes locales for further usage.
896
978
  </span> <span class='comment'>#
897
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
898
- </span> <span class='comment'># @return [DateTime] The extracted value.
979
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
980
+ </span> <span class='comment'># @return [Array] The normalized locales.
981
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
982
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
983
+ <span class='kw'>end</span>
984
+
985
+ <span class='id identifier rubyid_private'>private</span>
986
+
987
+ <span class='comment'># :nodoc:
899
988
  </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>
900
989
  <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>
901
990
  <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>
@@ -903,10 +992,7 @@
903
992
  <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>
904
993
  <span class='kw'>end</span>
905
994
 
906
- <span class='comment'># Parses a datetime.
907
- </span> <span class='comment'>#
908
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
909
- </span> <span class='comment'># @return [DateTime] The extracted value.
995
+ <span class='comment'># :nodoc:
910
996
  </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>
911
997
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
912
998
  <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>
@@ -920,19 +1006,13 @@
920
1006
  <span class='id identifier rubyid_rv'>rv</span>
921
1007
  <span class='kw'>end</span>
922
1008
 
923
- <span class='comment'># Parses a datetime from a number.
924
- </span> <span class='comment'>#
925
- </span> <span class='comment'># @param value [String] The value to parse.
926
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
1009
+ <span class='comment'># :nodoc:
927
1010
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
928
1011
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
929
1012
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
930
1013
  <span class='kw'>end</span>
931
1014
 
932
- <span class='comment'># Parses a datetime from a string.
933
- </span> <span class='comment'>#
934
- </span> <span class='comment'># @param value [String] The value to parse.
935
- </span> <span class='comment'># @return [DateTime] The extracted value.
1015
+ <span class='comment'># :nodoc:
936
1016
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
937
1017
  <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_string'>ensure_string</span>
938
1018
 
@@ -947,53 +1027,15 @@
947
1027
  <span class='kw'>end</span>
948
1028
  <span class='kw'>end</span>
949
1029
 
950
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
951
- </span> <span class='comment'>#
952
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
953
- </span> <span class='comment'># @return [Array] The list of tags.
1030
+ <span class='comment'># :nodoc:
954
1031
  </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>
955
- <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>
1032
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
956
1033
  <span class='kw'>end</span>
957
1034
 
958
- <span class='comment'># Check if value is an Hash.
959
- </span> <span class='comment'>#
960
- </span> <span class='comment'># @param value [Object] The object to check.
961
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
1035
+ <span class='comment'># :nodoc:
962
1036
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
963
1037
  <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>
964
1038
  <span class='kw'>end</span>
965
-
966
- <span class='comment'># Assigns metadata to a content
967
- </span> <span class='comment'>#
968
- </span> <span class='comment'># @param content [Content] The content to manipulate.
969
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
970
- </span> <span class='comment'># @return [Content] The content with metadata.
971
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
972
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
973
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
974
- <span class='kw'>end</span>
975
-
976
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
977
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
978
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
979
- <span class='kw'>end</span>
980
-
981
- <span class='comment'># Extracts locales from metadata.
982
- </span> <span class='comment'>#
983
- </span> <span class='comment'># @param locales [String] The list of locales.
984
- </span> <span class='comment'># @return [Array] The locales.
985
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
986
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
987
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
988
- <span class='kw'>end</span>
989
-
990
- <span class='comment'># Normalizes locales for further usage.
991
- </span> <span class='comment'>#
992
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
993
- </span> <span class='comment'># @return [Array] The normalized locales.
994
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
995
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
996
- <span class='kw'>end</span>
997
1039
  <span class='kw'>end</span></pre>
998
1040
  </td>
999
1041
  </tr>
@@ -1230,25 +1272,7 @@
1230
1272
  219
1231
1273
  220
1232
1274
  221
1233
- 222
1234
- 223
1235
- 224
1236
- 225
1237
- 226
1238
- 227
1239
- 228
1240
- 229
1241
- 230
1242
- 231
1243
- 232
1244
- 233
1245
- 234
1246
- 235
1247
- 236
1248
- 237
1249
- 238
1250
- 239
1251
- 240</pre>
1275
+ 222</pre>
1252
1276
  </td>
1253
1277
  <td>
1254
1278
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -1276,7 +1300,7 @@
1276
1300
  </span> <span class='comment'>#
1277
1301
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
1278
1302
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1279
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
1303
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
1280
1304
  <span class='kw'>end</span>
1281
1305
 
1282
1306
  <span class='comment'># Sets the `title` attribute.
@@ -1284,7 +1308,7 @@
1284
1308
  </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.
1285
1309
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1286
1310
  </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>
1287
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
1311
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
1288
1312
  <span class='kw'>end</span>
1289
1313
 
1290
1314
  <span class='comment'># Sets the `summary` attribute.
@@ -1292,7 +1316,7 @@
1292
1316
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
1293
1317
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1294
1318
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
1295
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1319
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1296
1320
  <span class='kw'>end</span>
1297
1321
 
1298
1322
  <span class='comment'># Sets the `body` attribute.
@@ -1307,7 +1331,7 @@
1307
1331
  </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.
1308
1332
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
1309
1333
  </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>
1310
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
1334
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
1311
1335
  <span class='kw'>end</span>
1312
1336
 
1313
1337
  <span class='comment'># Sets the `more` attribute.
@@ -1315,7 +1339,7 @@
1315
1339
  </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.
1316
1340
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1317
1341
  </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>
1318
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
1342
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
1319
1343
  <span class='kw'>end</span>
1320
1344
 
1321
1345
  <span class='comment'># Sets the `author` attribute.
@@ -1325,8 +1349,8 @@
1325
1349
  <span class='ivar'>@author</span> <span class='op'>=</span>
1326
1350
  <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>
1327
1351
  <span class='id identifier rubyid_new_author'>new_author</span>
1328
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
1329
- <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='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='rparen'>)</span>
1352
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
1353
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
1330
1354
  <span class='kw'>else</span>
1331
1355
  <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>
1332
1356
  <span class='kw'>end</span>
@@ -1350,15 +1374,44 @@
1350
1374
  </span> <span class='comment'>#
1351
1375
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
1352
1376
  </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>
1353
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
1377
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
1354
1378
  <span class='kw'>end</span>
1355
1379
 
1356
- <span class='id identifier rubyid_private'>private</span>
1380
+ <span class='comment'># Assigns metadata to a content
1381
+ </span> <span class='comment'>#
1382
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
1383
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
1384
+ </span> <span class='comment'># @return [Content] The content with metadata.
1385
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
1386
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
1387
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
1388
+ <span class='kw'>end</span>
1389
+
1390
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
1391
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
1392
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
1393
+ <span class='kw'>end</span>
1394
+
1395
+ <span class='comment'># Extracts locales from metadata.
1396
+ </span> <span class='comment'>#
1397
+ </span> <span class='comment'># @param locales [String] The list of locales.
1398
+ </span> <span class='comment'># @return [Array] The locales.
1399
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1400
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
1401
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1402
+ <span class='kw'>end</span>
1357
1403
 
1358
- <span class='comment'># Extracts a date and time from a value.
1404
+ <span class='comment'># Normalizes locales for further usage.
1359
1405
  </span> <span class='comment'>#
1360
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1361
- </span> <span class='comment'># @return [DateTime] The extracted value.
1406
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
1407
+ </span> <span class='comment'># @return [Array] The normalized locales.
1408
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1409
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
1410
+ <span class='kw'>end</span>
1411
+
1412
+ <span class='id identifier rubyid_private'>private</span>
1413
+
1414
+ <span class='comment'># :nodoc:
1362
1415
  </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>
1363
1416
  <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>
1364
1417
  <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>
@@ -1366,10 +1419,7 @@
1366
1419
  <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>
1367
1420
  <span class='kw'>end</span>
1368
1421
 
1369
- <span class='comment'># Parses a datetime.
1370
- </span> <span class='comment'>#
1371
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1372
- </span> <span class='comment'># @return [DateTime] The extracted value.
1422
+ <span class='comment'># :nodoc:
1373
1423
  </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>
1374
1424
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
1375
1425
  <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>
@@ -1383,19 +1433,13 @@
1383
1433
  <span class='id identifier rubyid_rv'>rv</span>
1384
1434
  <span class='kw'>end</span>
1385
1435
 
1386
- <span class='comment'># Parses a datetime from a number.
1387
- </span> <span class='comment'>#
1388
- </span> <span class='comment'># @param value [String] The value to parse.
1389
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
1436
+ <span class='comment'># :nodoc:
1390
1437
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1391
1438
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
1392
1439
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
1393
1440
  <span class='kw'>end</span>
1394
1441
 
1395
- <span class='comment'># Parses a datetime from a string.
1396
- </span> <span class='comment'>#
1397
- </span> <span class='comment'># @param value [String] The value to parse.
1398
- </span> <span class='comment'># @return [DateTime] The extracted value.
1442
+ <span class='comment'># :nodoc:
1399
1443
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1400
1444
  <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_string'>ensure_string</span>
1401
1445
 
@@ -1410,53 +1454,15 @@
1410
1454
  <span class='kw'>end</span>
1411
1455
  <span class='kw'>end</span>
1412
1456
 
1413
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
1414
- </span> <span class='comment'>#
1415
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
1416
- </span> <span class='comment'># @return [Array] The list of tags.
1457
+ <span class='comment'># :nodoc:
1417
1458
  </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>
1418
- <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>
1459
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
1419
1460
  <span class='kw'>end</span>
1420
1461
 
1421
- <span class='comment'># Check if value is an Hash.
1422
- </span> <span class='comment'>#
1423
- </span> <span class='comment'># @param value [Object] The object to check.
1424
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
1462
+ <span class='comment'># :nodoc:
1425
1463
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1426
1464
  <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>
1427
1465
  <span class='kw'>end</span>
1428
-
1429
- <span class='comment'># Assigns metadata to a content
1430
- </span> <span class='comment'>#
1431
- </span> <span class='comment'># @param content [Content] The content to manipulate.
1432
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
1433
- </span> <span class='comment'># @return [Content] The content with metadata.
1434
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
1435
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
1436
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
1437
- <span class='kw'>end</span>
1438
-
1439
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
1440
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
1441
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
1442
- <span class='kw'>end</span>
1443
-
1444
- <span class='comment'># Extracts locales from metadata.
1445
- </span> <span class='comment'>#
1446
- </span> <span class='comment'># @param locales [String] The list of locales.
1447
- </span> <span class='comment'># @return [Array] The locales.
1448
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1449
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
1450
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1451
- <span class='kw'>end</span>
1452
-
1453
- <span class='comment'># Normalizes locales for further usage.
1454
- </span> <span class='comment'>#
1455
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
1456
- </span> <span class='comment'># @return [Array] The normalized locales.
1457
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1458
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
1459
- <span class='kw'>end</span>
1460
1466
  <span class='kw'>end</span></pre>
1461
1467
  </td>
1462
1468
  </tr>
@@ -1693,25 +1699,7 @@
1693
1699
  219
1694
1700
  220
1695
1701
  221
1696
- 222
1697
- 223
1698
- 224
1699
- 225
1700
- 226
1701
- 227
1702
- 228
1703
- 229
1704
- 230
1705
- 231
1706
- 232
1707
- 233
1708
- 234
1709
- 235
1710
- 236
1711
- 237
1712
- 238
1713
- 239
1714
- 240</pre>
1702
+ 222</pre>
1715
1703
  </td>
1716
1704
  <td>
1717
1705
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -1739,7 +1727,7 @@
1739
1727
  </span> <span class='comment'>#
1740
1728
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
1741
1729
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1742
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
1730
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
1743
1731
  <span class='kw'>end</span>
1744
1732
 
1745
1733
  <span class='comment'># Sets the `title` attribute.
@@ -1747,7 +1735,7 @@
1747
1735
  </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.
1748
1736
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1749
1737
  </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>
1750
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
1738
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
1751
1739
  <span class='kw'>end</span>
1752
1740
 
1753
1741
  <span class='comment'># Sets the `summary` attribute.
@@ -1755,7 +1743,7 @@
1755
1743
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
1756
1744
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1757
1745
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
1758
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1746
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1759
1747
  <span class='kw'>end</span>
1760
1748
 
1761
1749
  <span class='comment'># Sets the `body` attribute.
@@ -1770,7 +1758,7 @@
1770
1758
  </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.
1771
1759
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
1772
1760
  </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>
1773
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
1761
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
1774
1762
  <span class='kw'>end</span>
1775
1763
 
1776
1764
  <span class='comment'># Sets the `more` attribute.
@@ -1778,7 +1766,7 @@
1778
1766
  </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.
1779
1767
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
1780
1768
  </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>
1781
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
1769
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
1782
1770
  <span class='kw'>end</span>
1783
1771
 
1784
1772
  <span class='comment'># Sets the `author` attribute.
@@ -1788,8 +1776,8 @@
1788
1776
  <span class='ivar'>@author</span> <span class='op'>=</span>
1789
1777
  <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>
1790
1778
  <span class='id identifier rubyid_new_author'>new_author</span>
1791
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
1792
- <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='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='rparen'>)</span>
1779
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
1780
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
1793
1781
  <span class='kw'>else</span>
1794
1782
  <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>
1795
1783
  <span class='kw'>end</span>
@@ -1813,15 +1801,44 @@
1813
1801
  </span> <span class='comment'>#
1814
1802
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
1815
1803
  </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>
1816
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
1804
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
1817
1805
  <span class='kw'>end</span>
1818
1806
 
1819
- <span class='id identifier rubyid_private'>private</span>
1807
+ <span class='comment'># Assigns metadata to a content
1808
+ </span> <span class='comment'>#
1809
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
1810
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
1811
+ </span> <span class='comment'># @return [Content] The content with metadata.
1812
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
1813
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
1814
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
1815
+ <span class='kw'>end</span>
1816
+
1817
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
1818
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
1819
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
1820
+ <span class='kw'>end</span>
1821
+
1822
+ <span class='comment'># Extracts locales from metadata.
1823
+ </span> <span class='comment'>#
1824
+ </span> <span class='comment'># @param locales [String] The list of locales.
1825
+ </span> <span class='comment'># @return [Array] The locales.
1826
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1827
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
1828
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1829
+ <span class='kw'>end</span>
1820
1830
 
1821
- <span class='comment'># Extracts a date and time from a value.
1831
+ <span class='comment'># Normalizes locales for further usage.
1822
1832
  </span> <span class='comment'>#
1823
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1824
- </span> <span class='comment'># @return [DateTime] The extracted value.
1833
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
1834
+ </span> <span class='comment'># @return [Array] The normalized locales.
1835
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1836
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
1837
+ <span class='kw'>end</span>
1838
+
1839
+ <span class='id identifier rubyid_private'>private</span>
1840
+
1841
+ <span class='comment'># :nodoc:
1825
1842
  </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>
1826
1843
  <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>
1827
1844
  <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>
@@ -1829,10 +1846,7 @@
1829
1846
  <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>
1830
1847
  <span class='kw'>end</span>
1831
1848
 
1832
- <span class='comment'># Parses a datetime.
1833
- </span> <span class='comment'>#
1834
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1835
- </span> <span class='comment'># @return [DateTime] The extracted value.
1849
+ <span class='comment'># :nodoc:
1836
1850
  </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>
1837
1851
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
1838
1852
  <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>
@@ -1846,19 +1860,13 @@
1846
1860
  <span class='id identifier rubyid_rv'>rv</span>
1847
1861
  <span class='kw'>end</span>
1848
1862
 
1849
- <span class='comment'># Parses a datetime from a number.
1850
- </span> <span class='comment'>#
1851
- </span> <span class='comment'># @param value [String] The value to parse.
1852
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
1863
+ <span class='comment'># :nodoc:
1853
1864
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1854
1865
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
1855
1866
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
1856
1867
  <span class='kw'>end</span>
1857
1868
 
1858
- <span class='comment'># Parses a datetime from a string.
1859
- </span> <span class='comment'>#
1860
- </span> <span class='comment'># @param value [String] The value to parse.
1861
- </span> <span class='comment'># @return [DateTime] The extracted value.
1869
+ <span class='comment'># :nodoc:
1862
1870
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1863
1871
  <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_string'>ensure_string</span>
1864
1872
 
@@ -1873,53 +1881,15 @@
1873
1881
  <span class='kw'>end</span>
1874
1882
  <span class='kw'>end</span>
1875
1883
 
1876
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
1877
- </span> <span class='comment'>#
1878
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
1879
- </span> <span class='comment'># @return [Array] The list of tags.
1884
+ <span class='comment'># :nodoc:
1880
1885
  </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>
1881
- <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>
1886
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
1882
1887
  <span class='kw'>end</span>
1883
1888
 
1884
- <span class='comment'># Check if value is an Hash.
1885
- </span> <span class='comment'>#
1886
- </span> <span class='comment'># @param value [Object] The object to check.
1887
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
1889
+ <span class='comment'># :nodoc:
1888
1890
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1889
1891
  <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>
1890
1892
  <span class='kw'>end</span>
1891
-
1892
- <span class='comment'># Assigns metadata to a content
1893
- </span> <span class='comment'>#
1894
- </span> <span class='comment'># @param content [Content] The content to manipulate.
1895
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
1896
- </span> <span class='comment'># @return [Content] The content with metadata.
1897
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
1898
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
1899
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
1900
- <span class='kw'>end</span>
1901
-
1902
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
1903
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
1904
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
1905
- <span class='kw'>end</span>
1906
-
1907
- <span class='comment'># Extracts locales from metadata.
1908
- </span> <span class='comment'>#
1909
- </span> <span class='comment'># @param locales [String] The list of locales.
1910
- </span> <span class='comment'># @return [Array] The locales.
1911
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1912
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
1913
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1914
- <span class='kw'>end</span>
1915
-
1916
- <span class='comment'># Normalizes locales for further usage.
1917
- </span> <span class='comment'>#
1918
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
1919
- </span> <span class='comment'># @return [Array] The normalized locales.
1920
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1921
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
1922
- <span class='kw'>end</span>
1923
1893
  <span class='kw'>end</span></pre>
1924
1894
  </td>
1925
1895
  </tr>
@@ -2156,25 +2126,7 @@
2156
2126
  219
2157
2127
  220
2158
2128
  221
2159
- 222
2160
- 223
2161
- 224
2162
- 225
2163
- 226
2164
- 227
2165
- 228
2166
- 229
2167
- 230
2168
- 231
2169
- 232
2170
- 233
2171
- 234
2172
- 235
2173
- 236
2174
- 237
2175
- 238
2176
- 239
2177
- 240</pre>
2129
+ 222</pre>
2178
2130
  </td>
2179
2131
  <td>
2180
2132
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -2202,7 +2154,7 @@
2202
2154
  </span> <span class='comment'>#
2203
2155
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
2204
2156
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2205
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
2157
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
2206
2158
  <span class='kw'>end</span>
2207
2159
 
2208
2160
  <span class='comment'># Sets the `title` attribute.
@@ -2210,7 +2162,7 @@
2210
2162
  </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.
2211
2163
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2212
2164
  </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>
2213
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
2165
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
2214
2166
  <span class='kw'>end</span>
2215
2167
 
2216
2168
  <span class='comment'># Sets the `summary` attribute.
@@ -2218,7 +2170,7 @@
2218
2170
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
2219
2171
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2220
2172
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
2221
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2173
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2222
2174
  <span class='kw'>end</span>
2223
2175
 
2224
2176
  <span class='comment'># Sets the `body` attribute.
@@ -2233,7 +2185,7 @@
2233
2185
  </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.
2234
2186
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
2235
2187
  </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>
2236
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
2188
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
2237
2189
  <span class='kw'>end</span>
2238
2190
 
2239
2191
  <span class='comment'># Sets the `more` attribute.
@@ -2241,7 +2193,7 @@
2241
2193
  </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.
2242
2194
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2243
2195
  </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>
2244
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
2196
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
2245
2197
  <span class='kw'>end</span>
2246
2198
 
2247
2199
  <span class='comment'># Sets the `author` attribute.
@@ -2251,8 +2203,8 @@
2251
2203
  <span class='ivar'>@author</span> <span class='op'>=</span>
2252
2204
  <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>
2253
2205
  <span class='id identifier rubyid_new_author'>new_author</span>
2254
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
2255
- <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='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='rparen'>)</span>
2206
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
2207
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
2256
2208
  <span class='kw'>else</span>
2257
2209
  <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>
2258
2210
  <span class='kw'>end</span>
@@ -2276,15 +2228,44 @@
2276
2228
  </span> <span class='comment'>#
2277
2229
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
2278
2230
  </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>
2279
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
2231
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
2280
2232
  <span class='kw'>end</span>
2281
2233
 
2282
- <span class='id identifier rubyid_private'>private</span>
2234
+ <span class='comment'># Assigns metadata to a content
2235
+ </span> <span class='comment'>#
2236
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
2237
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
2238
+ </span> <span class='comment'># @return [Content] The content with metadata.
2239
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
2240
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
2241
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
2242
+ <span class='kw'>end</span>
2243
+
2244
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
2245
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
2246
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
2247
+ <span class='kw'>end</span>
2248
+
2249
+ <span class='comment'># Extracts locales from metadata.
2250
+ </span> <span class='comment'>#
2251
+ </span> <span class='comment'># @param locales [String] The list of locales.
2252
+ </span> <span class='comment'># @return [Array] The locales.
2253
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2254
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
2255
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2256
+ <span class='kw'>end</span>
2283
2257
 
2284
- <span class='comment'># Extracts a date and time from a value.
2258
+ <span class='comment'># Normalizes locales for further usage.
2285
2259
  </span> <span class='comment'>#
2286
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2287
- </span> <span class='comment'># @return [DateTime] The extracted value.
2260
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
2261
+ </span> <span class='comment'># @return [Array] The normalized locales.
2262
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2263
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
2264
+ <span class='kw'>end</span>
2265
+
2266
+ <span class='id identifier rubyid_private'>private</span>
2267
+
2268
+ <span class='comment'># :nodoc:
2288
2269
  </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>
2289
2270
  <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>
2290
2271
  <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>
@@ -2292,10 +2273,7 @@
2292
2273
  <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>
2293
2274
  <span class='kw'>end</span>
2294
2275
 
2295
- <span class='comment'># Parses a datetime.
2296
- </span> <span class='comment'>#
2297
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2298
- </span> <span class='comment'># @return [DateTime] The extracted value.
2276
+ <span class='comment'># :nodoc:
2299
2277
  </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>
2300
2278
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
2301
2279
  <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>
@@ -2309,19 +2287,13 @@
2309
2287
  <span class='id identifier rubyid_rv'>rv</span>
2310
2288
  <span class='kw'>end</span>
2311
2289
 
2312
- <span class='comment'># Parses a datetime from a number.
2313
- </span> <span class='comment'>#
2314
- </span> <span class='comment'># @param value [String] The value to parse.
2315
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
2290
+ <span class='comment'># :nodoc:
2316
2291
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2317
2292
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
2318
2293
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
2319
2294
  <span class='kw'>end</span>
2320
2295
 
2321
- <span class='comment'># Parses a datetime from a string.
2322
- </span> <span class='comment'>#
2323
- </span> <span class='comment'># @param value [String] The value to parse.
2324
- </span> <span class='comment'># @return [DateTime] The extracted value.
2296
+ <span class='comment'># :nodoc:
2325
2297
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2326
2298
  <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_string'>ensure_string</span>
2327
2299
 
@@ -2336,53 +2308,15 @@
2336
2308
  <span class='kw'>end</span>
2337
2309
  <span class='kw'>end</span>
2338
2310
 
2339
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
2340
- </span> <span class='comment'>#
2341
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
2342
- </span> <span class='comment'># @return [Array] The list of tags.
2311
+ <span class='comment'># :nodoc:
2343
2312
  </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>
2344
- <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>
2313
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
2345
2314
  <span class='kw'>end</span>
2346
2315
 
2347
- <span class='comment'># Check if value is an Hash.
2348
- </span> <span class='comment'>#
2349
- </span> <span class='comment'># @param value [Object] The object to check.
2350
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
2316
+ <span class='comment'># :nodoc:
2351
2317
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2352
2318
  <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>
2353
2319
  <span class='kw'>end</span>
2354
-
2355
- <span class='comment'># Assigns metadata to a content
2356
- </span> <span class='comment'>#
2357
- </span> <span class='comment'># @param content [Content] The content to manipulate.
2358
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
2359
- </span> <span class='comment'># @return [Content] The content with metadata.
2360
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
2361
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
2362
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
2363
- <span class='kw'>end</span>
2364
-
2365
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
2366
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
2367
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
2368
- <span class='kw'>end</span>
2369
-
2370
- <span class='comment'># Extracts locales from metadata.
2371
- </span> <span class='comment'>#
2372
- </span> <span class='comment'># @param locales [String] The list of locales.
2373
- </span> <span class='comment'># @return [Array] The locales.
2374
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2375
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
2376
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2377
- <span class='kw'>end</span>
2378
-
2379
- <span class='comment'># Normalizes locales for further usage.
2380
- </span> <span class='comment'>#
2381
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
2382
- </span> <span class='comment'># @return [Array] The normalized locales.
2383
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2384
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
2385
- <span class='kw'>end</span>
2386
2320
  <span class='kw'>end</span></pre>
2387
2321
  </td>
2388
2322
  </tr>
@@ -2619,25 +2553,7 @@
2619
2553
  219
2620
2554
  220
2621
2555
  221
2622
- 222
2623
- 223
2624
- 224
2625
- 225
2626
- 226
2627
- 227
2628
- 228
2629
- 229
2630
- 230
2631
- 231
2632
- 232
2633
- 233
2634
- 234
2635
- 235
2636
- 236
2637
- 237
2638
- 238
2639
- 239
2640
- 240</pre>
2556
+ 222</pre>
2641
2557
  </td>
2642
2558
  <td>
2643
2559
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -2665,7 +2581,7 @@
2665
2581
  </span> <span class='comment'>#
2666
2582
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
2667
2583
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2668
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
2584
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
2669
2585
  <span class='kw'>end</span>
2670
2586
 
2671
2587
  <span class='comment'># Sets the `title` attribute.
@@ -2673,7 +2589,7 @@
2673
2589
  </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.
2674
2590
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2675
2591
  </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>
2676
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
2592
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
2677
2593
  <span class='kw'>end</span>
2678
2594
 
2679
2595
  <span class='comment'># Sets the `summary` attribute.
@@ -2681,7 +2597,7 @@
2681
2597
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
2682
2598
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2683
2599
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
2684
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2600
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2685
2601
  <span class='kw'>end</span>
2686
2602
 
2687
2603
  <span class='comment'># Sets the `body` attribute.
@@ -2696,7 +2612,7 @@
2696
2612
  </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.
2697
2613
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
2698
2614
  </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>
2699
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
2615
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
2700
2616
  <span class='kw'>end</span>
2701
2617
 
2702
2618
  <span class='comment'># Sets the `more` attribute.
@@ -2704,7 +2620,7 @@
2704
2620
  </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.
2705
2621
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
2706
2622
  </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>
2707
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
2623
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
2708
2624
  <span class='kw'>end</span>
2709
2625
 
2710
2626
  <span class='comment'># Sets the `author` attribute.
@@ -2714,8 +2630,8 @@
2714
2630
  <span class='ivar'>@author</span> <span class='op'>=</span>
2715
2631
  <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>
2716
2632
  <span class='id identifier rubyid_new_author'>new_author</span>
2717
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
2718
- <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='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='rparen'>)</span>
2633
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
2634
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
2719
2635
  <span class='kw'>else</span>
2720
2636
  <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>
2721
2637
  <span class='kw'>end</span>
@@ -2739,15 +2655,44 @@
2739
2655
  </span> <span class='comment'>#
2740
2656
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
2741
2657
  </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>
2742
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
2658
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
2743
2659
  <span class='kw'>end</span>
2744
2660
 
2745
- <span class='id identifier rubyid_private'>private</span>
2661
+ <span class='comment'># Assigns metadata to a content
2662
+ </span> <span class='comment'>#
2663
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
2664
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
2665
+ </span> <span class='comment'># @return [Content] The content with metadata.
2666
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
2667
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
2668
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
2669
+ <span class='kw'>end</span>
2670
+
2671
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
2672
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
2673
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
2674
+ <span class='kw'>end</span>
2675
+
2676
+ <span class='comment'># Extracts locales from metadata.
2677
+ </span> <span class='comment'>#
2678
+ </span> <span class='comment'># @param locales [String] The list of locales.
2679
+ </span> <span class='comment'># @return [Array] The locales.
2680
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2681
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
2682
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2683
+ <span class='kw'>end</span>
2746
2684
 
2747
- <span class='comment'># Extracts a date and time from a value.
2685
+ <span class='comment'># Normalizes locales for further usage.
2748
2686
  </span> <span class='comment'>#
2749
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2750
- </span> <span class='comment'># @return [DateTime] The extracted value.
2687
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
2688
+ </span> <span class='comment'># @return [Array] The normalized locales.
2689
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2690
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
2691
+ <span class='kw'>end</span>
2692
+
2693
+ <span class='id identifier rubyid_private'>private</span>
2694
+
2695
+ <span class='comment'># :nodoc:
2751
2696
  </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>
2752
2697
  <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>
2753
2698
  <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>
@@ -2755,10 +2700,7 @@
2755
2700
  <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>
2756
2701
  <span class='kw'>end</span>
2757
2702
 
2758
- <span class='comment'># Parses a datetime.
2759
- </span> <span class='comment'>#
2760
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2761
- </span> <span class='comment'># @return [DateTime] The extracted value.
2703
+ <span class='comment'># :nodoc:
2762
2704
  </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>
2763
2705
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
2764
2706
  <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>
@@ -2772,19 +2714,13 @@
2772
2714
  <span class='id identifier rubyid_rv'>rv</span>
2773
2715
  <span class='kw'>end</span>
2774
2716
 
2775
- <span class='comment'># Parses a datetime from a number.
2776
- </span> <span class='comment'>#
2777
- </span> <span class='comment'># @param value [String] The value to parse.
2778
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
2717
+ <span class='comment'># :nodoc:
2779
2718
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2780
2719
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
2781
2720
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
2782
2721
  <span class='kw'>end</span>
2783
2722
 
2784
- <span class='comment'># Parses a datetime from a string.
2785
- </span> <span class='comment'>#
2786
- </span> <span class='comment'># @param value [String] The value to parse.
2787
- </span> <span class='comment'># @return [DateTime] The extracted value.
2723
+ <span class='comment'># :nodoc:
2788
2724
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2789
2725
  <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_string'>ensure_string</span>
2790
2726
 
@@ -2799,53 +2735,15 @@
2799
2735
  <span class='kw'>end</span>
2800
2736
  <span class='kw'>end</span>
2801
2737
 
2802
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
2803
- </span> <span class='comment'>#
2804
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
2805
- </span> <span class='comment'># @return [Array] The list of tags.
2738
+ <span class='comment'># :nodoc:
2806
2739
  </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>
2807
- <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>
2740
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
2808
2741
  <span class='kw'>end</span>
2809
2742
 
2810
- <span class='comment'># Check if value is an Hash.
2811
- </span> <span class='comment'>#
2812
- </span> <span class='comment'># @param value [Object] The object to check.
2813
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
2743
+ <span class='comment'># :nodoc:
2814
2744
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2815
2745
  <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>
2816
2746
  <span class='kw'>end</span>
2817
-
2818
- <span class='comment'># Assigns metadata to a content
2819
- </span> <span class='comment'>#
2820
- </span> <span class='comment'># @param content [Content] The content to manipulate.
2821
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
2822
- </span> <span class='comment'># @return [Content] The content with metadata.
2823
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
2824
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
2825
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
2826
- <span class='kw'>end</span>
2827
-
2828
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
2829
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
2830
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
2831
- <span class='kw'>end</span>
2832
-
2833
- <span class='comment'># Extracts locales from metadata.
2834
- </span> <span class='comment'>#
2835
- </span> <span class='comment'># @param locales [String] The list of locales.
2836
- </span> <span class='comment'># @return [Array] The locales.
2837
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2838
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
2839
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2840
- <span class='kw'>end</span>
2841
-
2842
- <span class='comment'># Normalizes locales for further usage.
2843
- </span> <span class='comment'>#
2844
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
2845
- </span> <span class='comment'># @return [Array] The normalized locales.
2846
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2847
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
2848
- <span class='kw'>end</span>
2849
2747
  <span class='kw'>end</span></pre>
2850
2748
  </td>
2851
2749
  </tr>
@@ -3126,25 +3024,7 @@ for multiple locales.</p>
3126
3024
  219
3127
3025
  220
3128
3026
  221
3129
- 222
3130
- 223
3131
- 224
3132
- 225
3133
- 226
3134
- 227
3135
- 228
3136
- 229
3137
- 230
3138
- 231
3139
- 232
3140
- 233
3141
- 234
3142
- 235
3143
- 236
3144
- 237
3145
- 238
3146
- 239
3147
- 240</pre>
3027
+ 222</pre>
3148
3028
  </td>
3149
3029
  <td>
3150
3030
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -3172,7 +3052,7 @@ for multiple locales.</p>
3172
3052
  </span> <span class='comment'>#
3173
3053
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
3174
3054
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3175
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
3055
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
3176
3056
  <span class='kw'>end</span>
3177
3057
 
3178
3058
  <span class='comment'># Sets the `title` attribute.
@@ -3180,7 +3060,7 @@ for multiple locales.</p>
3180
3060
  </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.
3181
3061
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
3182
3062
  </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>
3183
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
3063
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
3184
3064
  <span class='kw'>end</span>
3185
3065
 
3186
3066
  <span class='comment'># Sets the `summary` attribute.
@@ -3188,7 +3068,7 @@ for multiple locales.</p>
3188
3068
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
3189
3069
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
3190
3070
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
3191
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3071
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3192
3072
  <span class='kw'>end</span>
3193
3073
 
3194
3074
  <span class='comment'># Sets the `body` attribute.
@@ -3203,7 +3083,7 @@ for multiple locales.</p>
3203
3083
  </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.
3204
3084
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
3205
3085
  </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>
3206
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
3086
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
3207
3087
  <span class='kw'>end</span>
3208
3088
 
3209
3089
  <span class='comment'># Sets the `more` attribute.
@@ -3211,7 +3091,7 @@ for multiple locales.</p>
3211
3091
  </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.
3212
3092
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
3213
3093
  </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>
3214
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
3094
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
3215
3095
  <span class='kw'>end</span>
3216
3096
 
3217
3097
  <span class='comment'># Sets the `author` attribute.
@@ -3221,8 +3101,8 @@ for multiple locales.</p>
3221
3101
  <span class='ivar'>@author</span> <span class='op'>=</span>
3222
3102
  <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>
3223
3103
  <span class='id identifier rubyid_new_author'>new_author</span>
3224
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
3225
- <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='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='rparen'>)</span>
3104
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
3105
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
3226
3106
  <span class='kw'>else</span>
3227
3107
  <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>
3228
3108
  <span class='kw'>end</span>
@@ -3246,15 +3126,44 @@ for multiple locales.</p>
3246
3126
  </span> <span class='comment'>#
3247
3127
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
3248
3128
  </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>
3249
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
3129
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
3250
3130
  <span class='kw'>end</span>
3251
3131
 
3252
- <span class='id identifier rubyid_private'>private</span>
3132
+ <span class='comment'># Assigns metadata to a content
3133
+ </span> <span class='comment'>#
3134
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
3135
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
3136
+ </span> <span class='comment'># @return [Content] The content with metadata.
3137
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
3138
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
3139
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
3140
+ <span class='kw'>end</span>
3141
+
3142
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
3143
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
3144
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
3145
+ <span class='kw'>end</span>
3146
+
3147
+ <span class='comment'># Extracts locales from metadata.
3148
+ </span> <span class='comment'>#
3149
+ </span> <span class='comment'># @param locales [String] The list of locales.
3150
+ </span> <span class='comment'># @return [Array] The locales.
3151
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3152
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
3153
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3154
+ <span class='kw'>end</span>
3253
3155
 
3254
- <span class='comment'># Extracts a date and time from a value.
3156
+ <span class='comment'># Normalizes locales for further usage.
3255
3157
  </span> <span class='comment'>#
3256
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3257
- </span> <span class='comment'># @return [DateTime] The extracted value.
3158
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
3159
+ </span> <span class='comment'># @return [Array] The normalized locales.
3160
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3161
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
3162
+ <span class='kw'>end</span>
3163
+
3164
+ <span class='id identifier rubyid_private'>private</span>
3165
+
3166
+ <span class='comment'># :nodoc:
3258
3167
  </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>
3259
3168
  <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>
3260
3169
  <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>
@@ -3262,10 +3171,7 @@ for multiple locales.</p>
3262
3171
  <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>
3263
3172
  <span class='kw'>end</span>
3264
3173
 
3265
- <span class='comment'># Parses a datetime.
3266
- </span> <span class='comment'>#
3267
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3268
- </span> <span class='comment'># @return [DateTime] The extracted value.
3174
+ <span class='comment'># :nodoc:
3269
3175
  </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>
3270
3176
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
3271
3177
  <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>
@@ -3279,19 +3185,13 @@ for multiple locales.</p>
3279
3185
  <span class='id identifier rubyid_rv'>rv</span>
3280
3186
  <span class='kw'>end</span>
3281
3187
 
3282
- <span class='comment'># Parses a datetime from a number.
3283
- </span> <span class='comment'>#
3284
- </span> <span class='comment'># @param value [String] The value to parse.
3285
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
3188
+ <span class='comment'># :nodoc:
3286
3189
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3287
3190
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
3288
3191
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
3289
3192
  <span class='kw'>end</span>
3290
3193
 
3291
- <span class='comment'># Parses a datetime from a string.
3292
- </span> <span class='comment'>#
3293
- </span> <span class='comment'># @param value [String] The value to parse.
3294
- </span> <span class='comment'># @return [DateTime] The extracted value.
3194
+ <span class='comment'># :nodoc:
3295
3195
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3296
3196
  <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_string'>ensure_string</span>
3297
3197
 
@@ -3306,53 +3206,15 @@ for multiple locales.</p>
3306
3206
  <span class='kw'>end</span>
3307
3207
  <span class='kw'>end</span>
3308
3208
 
3309
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
3310
- </span> <span class='comment'>#
3311
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
3312
- </span> <span class='comment'># @return [Array] The list of tags.
3209
+ <span class='comment'># :nodoc:
3313
3210
  </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>
3314
- <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>
3211
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
3315
3212
  <span class='kw'>end</span>
3316
3213
 
3317
- <span class='comment'># Check if value is an Hash.
3318
- </span> <span class='comment'>#
3319
- </span> <span class='comment'># @param value [Object] The object to check.
3320
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
3214
+ <span class='comment'># :nodoc:
3321
3215
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3322
3216
  <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>
3323
3217
  <span class='kw'>end</span>
3324
-
3325
- <span class='comment'># Assigns metadata to a content
3326
- </span> <span class='comment'>#
3327
- </span> <span class='comment'># @param content [Content] The content to manipulate.
3328
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
3329
- </span> <span class='comment'># @return [Content] The content with metadata.
3330
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
3331
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
3332
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
3333
- <span class='kw'>end</span>
3334
-
3335
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
3336
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
3337
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
3338
- <span class='kw'>end</span>
3339
-
3340
- <span class='comment'># Extracts locales from metadata.
3341
- </span> <span class='comment'>#
3342
- </span> <span class='comment'># @param locales [String] The list of locales.
3343
- </span> <span class='comment'># @return [Array] The locales.
3344
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3345
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
3346
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3347
- <span class='kw'>end</span>
3348
-
3349
- <span class='comment'># Normalizes locales for further usage.
3350
- </span> <span class='comment'>#
3351
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
3352
- </span> <span class='comment'># @return [Array] The normalized locales.
3353
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3354
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
3355
- <span class='kw'>end</span>
3356
3218
  <span class='kw'>end</span></pre>
3357
3219
  </td>
3358
3220
  </tr>
@@ -3591,25 +3453,7 @@ are specified for multiple locales.</p>
3591
3453
  219
3592
3454
  220
3593
3455
  221
3594
- 222
3595
- 223
3596
- 224
3597
- 225
3598
- 226
3599
- 227
3600
- 228
3601
- 229
3602
- 230
3603
- 231
3604
- 232
3605
- 233
3606
- 234
3607
- 235
3608
- 236
3609
- 237
3610
- 238
3611
- 239
3612
- 240</pre>
3456
+ 222</pre>
3613
3457
  </td>
3614
3458
  <td>
3615
3459
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -3637,7 +3481,7 @@ are specified for multiple locales.</p>
3637
3481
  </span> <span class='comment'>#
3638
3482
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
3639
3483
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3640
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
3484
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
3641
3485
  <span class='kw'>end</span>
3642
3486
 
3643
3487
  <span class='comment'># Sets the `title` attribute.
@@ -3645,7 +3489,7 @@ are specified for multiple locales.</p>
3645
3489
  </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.
3646
3490
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
3647
3491
  </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>
3648
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
3492
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
3649
3493
  <span class='kw'>end</span>
3650
3494
 
3651
3495
  <span class='comment'># Sets the `summary` attribute.
@@ -3653,7 +3497,7 @@ are specified for multiple locales.</p>
3653
3497
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
3654
3498
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
3655
3499
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
3656
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3500
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3657
3501
  <span class='kw'>end</span>
3658
3502
 
3659
3503
  <span class='comment'># Sets the `body` attribute.
@@ -3668,7 +3512,7 @@ are specified for multiple locales.</p>
3668
3512
  </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.
3669
3513
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
3670
3514
  </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>
3671
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
3515
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
3672
3516
  <span class='kw'>end</span>
3673
3517
 
3674
3518
  <span class='comment'># Sets the `more` attribute.
@@ -3676,7 +3520,7 @@ are specified for multiple locales.</p>
3676
3520
  </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.
3677
3521
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
3678
3522
  </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>
3679
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
3523
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
3680
3524
  <span class='kw'>end</span>
3681
3525
 
3682
3526
  <span class='comment'># Sets the `author` attribute.
@@ -3686,8 +3530,8 @@ are specified for multiple locales.</p>
3686
3530
  <span class='ivar'>@author</span> <span class='op'>=</span>
3687
3531
  <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>
3688
3532
  <span class='id identifier rubyid_new_author'>new_author</span>
3689
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
3690
- <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='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='rparen'>)</span>
3533
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
3534
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
3691
3535
  <span class='kw'>else</span>
3692
3536
  <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>
3693
3537
  <span class='kw'>end</span>
@@ -3711,27 +3555,53 @@ are specified for multiple locales.</p>
3711
3555
  </span> <span class='comment'>#
3712
3556
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
3713
3557
  </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>
3714
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
3558
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
3715
3559
  <span class='kw'>end</span>
3716
3560
 
3717
- <span class='id identifier rubyid_private'>private</span>
3718
-
3719
- <span class='comment'># Extracts a date and time from a value.
3561
+ <span class='comment'># Assigns metadata to a content
3720
3562
  </span> <span class='comment'>#
3721
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3722
- </span> <span class='comment'># @return [DateTime] The extracted value.
3723
- </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>
3724
- <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>
3725
- <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>
3726
- <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
3727
- <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>
3563
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
3564
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
3565
+ </span> <span class='comment'># @return [Content] The content with metadata.
3566
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
3567
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
3568
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
3569
+ <span class='kw'>end</span>
3570
+
3571
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
3572
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
3573
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
3728
3574
  <span class='kw'>end</span>
3729
3575
 
3730
- <span class='comment'># Parses a datetime.
3576
+ <span class='comment'># Extracts locales from metadata.
3731
3577
  </span> <span class='comment'>#
3732
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3733
- </span> <span class='comment'># @return [DateTime] The extracted value.
3734
- </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>
3578
+ </span> <span class='comment'># @param locales [String] The list of locales.
3579
+ </span> <span class='comment'># @return [Array] The locales.
3580
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3581
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
3582
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3583
+ <span class='kw'>end</span>
3584
+
3585
+ <span class='comment'># Normalizes locales for further usage.
3586
+ </span> <span class='comment'>#
3587
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
3588
+ </span> <span class='comment'># @return [Array] The normalized locales.
3589
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3590
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
3591
+ <span class='kw'>end</span>
3592
+
3593
+ <span class='id identifier rubyid_private'>private</span>
3594
+
3595
+ <span class='comment'># :nodoc:
3596
+ </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>
3597
+ <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>
3598
+ <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>
3599
+ <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
3600
+ <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>
3601
+ <span class='kw'>end</span>
3602
+
3603
+ <span class='comment'># :nodoc:
3604
+ </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>
3735
3605
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
3736
3606
  <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>
3737
3607
  <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>
@@ -3744,19 +3614,13 @@ are specified for multiple locales.</p>
3744
3614
  <span class='id identifier rubyid_rv'>rv</span>
3745
3615
  <span class='kw'>end</span>
3746
3616
 
3747
- <span class='comment'># Parses a datetime from a number.
3748
- </span> <span class='comment'>#
3749
- </span> <span class='comment'># @param value [String] The value to parse.
3750
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
3617
+ <span class='comment'># :nodoc:
3751
3618
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3752
3619
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
3753
3620
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
3754
3621
  <span class='kw'>end</span>
3755
3622
 
3756
- <span class='comment'># Parses a datetime from a string.
3757
- </span> <span class='comment'>#
3758
- </span> <span class='comment'># @param value [String] The value to parse.
3759
- </span> <span class='comment'># @return [DateTime] The extracted value.
3623
+ <span class='comment'># :nodoc:
3760
3624
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3761
3625
  <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_string'>ensure_string</span>
3762
3626
 
@@ -3771,53 +3635,15 @@ are specified for multiple locales.</p>
3771
3635
  <span class='kw'>end</span>
3772
3636
  <span class='kw'>end</span>
3773
3637
 
3774
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
3775
- </span> <span class='comment'>#
3776
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
3777
- </span> <span class='comment'># @return [Array] The list of tags.
3638
+ <span class='comment'># :nodoc:
3778
3639
  </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>
3779
- <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>
3640
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
3780
3641
  <span class='kw'>end</span>
3781
3642
 
3782
- <span class='comment'># Check if value is an Hash.
3783
- </span> <span class='comment'>#
3784
- </span> <span class='comment'># @param value [Object] The object to check.
3785
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
3643
+ <span class='comment'># :nodoc:
3786
3644
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3787
3645
  <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>
3788
3646
  <span class='kw'>end</span>
3789
-
3790
- <span class='comment'># Assigns metadata to a content
3791
- </span> <span class='comment'>#
3792
- </span> <span class='comment'># @param content [Content] The content to manipulate.
3793
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
3794
- </span> <span class='comment'># @return [Content] The content with metadata.
3795
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
3796
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
3797
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
3798
- <span class='kw'>end</span>
3799
-
3800
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
3801
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
3802
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
3803
- <span class='kw'>end</span>
3804
-
3805
- <span class='comment'># Extracts locales from metadata.
3806
- </span> <span class='comment'>#
3807
- </span> <span class='comment'># @param locales [String] The list of locales.
3808
- </span> <span class='comment'># @return [Array] The locales.
3809
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3810
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
3811
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3812
- <span class='kw'>end</span>
3813
-
3814
- <span class='comment'># Normalizes locales for further usage.
3815
- </span> <span class='comment'>#
3816
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
3817
- </span> <span class='comment'># @return [Array] The normalized locales.
3818
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3819
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
3820
- <span class='kw'>end</span>
3821
3647
  <span class='kw'>end</span></pre>
3822
3648
  </td>
3823
3649
  </tr>
@@ -4056,25 +3882,7 @@ multiple locales.</p>
4056
3882
  219
4057
3883
  220
4058
3884
  221
4059
- 222
4060
- 223
4061
- 224
4062
- 225
4063
- 226
4064
- 227
4065
- 228
4066
- 229
4067
- 230
4068
- 231
4069
- 232
4070
- 233
4071
- 234
4072
- 235
4073
- 236
4074
- 237
4075
- 238
4076
- 239
4077
- 240</pre>
3885
+ 222</pre>
4078
3886
  </td>
4079
3887
  <td>
4080
3888
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -4102,7 +3910,7 @@ multiple locales.</p>
4102
3910
  </span> <span class='comment'>#
4103
3911
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
4104
3912
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4105
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
3913
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
4106
3914
  <span class='kw'>end</span>
4107
3915
 
4108
3916
  <span class='comment'># Sets the `title` attribute.
@@ -4110,7 +3918,7 @@ multiple locales.</p>
4110
3918
  </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.
4111
3919
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4112
3920
  </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>
4113
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
3921
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
4114
3922
  <span class='kw'>end</span>
4115
3923
 
4116
3924
  <span class='comment'># Sets the `summary` attribute.
@@ -4118,7 +3926,7 @@ multiple locales.</p>
4118
3926
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
4119
3927
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4120
3928
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
4121
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3929
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4122
3930
  <span class='kw'>end</span>
4123
3931
 
4124
3932
  <span class='comment'># Sets the `body` attribute.
@@ -4133,7 +3941,7 @@ multiple locales.</p>
4133
3941
  </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.
4134
3942
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
4135
3943
  </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>
4136
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
3944
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
4137
3945
  <span class='kw'>end</span>
4138
3946
 
4139
3947
  <span class='comment'># Sets the `more` attribute.
@@ -4141,7 +3949,7 @@ multiple locales.</p>
4141
3949
  </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.
4142
3950
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4143
3951
  </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>
4144
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
3952
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
4145
3953
  <span class='kw'>end</span>
4146
3954
 
4147
3955
  <span class='comment'># Sets the `author` attribute.
@@ -4151,8 +3959,8 @@ multiple locales.</p>
4151
3959
  <span class='ivar'>@author</span> <span class='op'>=</span>
4152
3960
  <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>
4153
3961
  <span class='id identifier rubyid_new_author'>new_author</span>
4154
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
4155
- <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='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='rparen'>)</span>
3962
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
3963
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
4156
3964
  <span class='kw'>else</span>
4157
3965
  <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>
4158
3966
  <span class='kw'>end</span>
@@ -4176,15 +3984,44 @@ multiple locales.</p>
4176
3984
  </span> <span class='comment'>#
4177
3985
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
4178
3986
  </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>
4179
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
3987
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
4180
3988
  <span class='kw'>end</span>
4181
3989
 
4182
- <span class='id identifier rubyid_private'>private</span>
3990
+ <span class='comment'># Assigns metadata to a content
3991
+ </span> <span class='comment'>#
3992
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
3993
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
3994
+ </span> <span class='comment'># @return [Content] The content with metadata.
3995
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
3996
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
3997
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
3998
+ <span class='kw'>end</span>
3999
+
4000
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
4001
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
4002
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
4003
+ <span class='kw'>end</span>
4183
4004
 
4184
- <span class='comment'># Extracts a date and time from a value.
4005
+ <span class='comment'># Extracts locales from metadata.
4185
4006
  </span> <span class='comment'>#
4186
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4187
- </span> <span class='comment'># @return [DateTime] The extracted value.
4007
+ </span> <span class='comment'># @param locales [String] The list of locales.
4008
+ </span> <span class='comment'># @return [Array] The locales.
4009
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4010
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
4011
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4012
+ <span class='kw'>end</span>
4013
+
4014
+ <span class='comment'># Normalizes locales for further usage.
4015
+ </span> <span class='comment'>#
4016
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
4017
+ </span> <span class='comment'># @return [Array] The normalized locales.
4018
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4019
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
4020
+ <span class='kw'>end</span>
4021
+
4022
+ <span class='id identifier rubyid_private'>private</span>
4023
+
4024
+ <span class='comment'># :nodoc:
4188
4025
  </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>
4189
4026
  <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>
4190
4027
  <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>
@@ -4192,10 +4029,7 @@ multiple locales.</p>
4192
4029
  <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>
4193
4030
  <span class='kw'>end</span>
4194
4031
 
4195
- <span class='comment'># Parses a datetime.
4196
- </span> <span class='comment'>#
4197
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4198
- </span> <span class='comment'># @return [DateTime] The extracted value.
4032
+ <span class='comment'># :nodoc:
4199
4033
  </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>
4200
4034
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
4201
4035
  <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>
@@ -4209,19 +4043,13 @@ multiple locales.</p>
4209
4043
  <span class='id identifier rubyid_rv'>rv</span>
4210
4044
  <span class='kw'>end</span>
4211
4045
 
4212
- <span class='comment'># Parses a datetime from a number.
4213
- </span> <span class='comment'>#
4214
- </span> <span class='comment'># @param value [String] The value to parse.
4215
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
4046
+ <span class='comment'># :nodoc:
4216
4047
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4217
4048
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
4218
4049
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
4219
4050
  <span class='kw'>end</span>
4220
4051
 
4221
- <span class='comment'># Parses a datetime from a string.
4222
- </span> <span class='comment'>#
4223
- </span> <span class='comment'># @param value [String] The value to parse.
4224
- </span> <span class='comment'># @return [DateTime] The extracted value.
4052
+ <span class='comment'># :nodoc:
4225
4053
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4226
4054
  <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_string'>ensure_string</span>
4227
4055
 
@@ -4236,53 +4064,15 @@ multiple locales.</p>
4236
4064
  <span class='kw'>end</span>
4237
4065
  <span class='kw'>end</span>
4238
4066
 
4239
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
4240
- </span> <span class='comment'>#
4241
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
4242
- </span> <span class='comment'># @return [Array] The list of tags.
4067
+ <span class='comment'># :nodoc:
4243
4068
  </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>
4244
- <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>
4069
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
4245
4070
  <span class='kw'>end</span>
4246
4071
 
4247
- <span class='comment'># Check if value is an Hash.
4248
- </span> <span class='comment'>#
4249
- </span> <span class='comment'># @param value [Object] The object to check.
4250
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
4072
+ <span class='comment'># :nodoc:
4251
4073
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4252
4074
  <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>
4253
4075
  <span class='kw'>end</span>
4254
-
4255
- <span class='comment'># Assigns metadata to a content
4256
- </span> <span class='comment'>#
4257
- </span> <span class='comment'># @param content [Content] The content to manipulate.
4258
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
4259
- </span> <span class='comment'># @return [Content] The content with metadata.
4260
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
4261
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
4262
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
4263
- <span class='kw'>end</span>
4264
-
4265
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
4266
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
4267
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
4268
- <span class='kw'>end</span>
4269
-
4270
- <span class='comment'># Extracts locales from metadata.
4271
- </span> <span class='comment'>#
4272
- </span> <span class='comment'># @param locales [String] The list of locales.
4273
- </span> <span class='comment'># @return [Array] The locales.
4274
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4275
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
4276
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4277
- <span class='kw'>end</span>
4278
-
4279
- <span class='comment'># Normalizes locales for further usage.
4280
- </span> <span class='comment'>#
4281
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
4282
- </span> <span class='comment'># @return [Array] The normalized locales.
4283
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4284
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
4285
- <span class='kw'>end</span>
4286
4076
  <span class='kw'>end</span></pre>
4287
4077
  </td>
4288
4078
  </tr>
@@ -4519,25 +4309,7 @@ multiple locales.</p>
4519
4309
  219
4520
4310
  220
4521
4311
  221
4522
- 222
4523
- 223
4524
- 224
4525
- 225
4526
- 226
4527
- 227
4528
- 228
4529
- 229
4530
- 230
4531
- 231
4532
- 232
4533
- 233
4534
- 234
4535
- 235
4536
- 236
4537
- 237
4538
- 238
4539
- 239
4540
- 240</pre>
4312
+ 222</pre>
4541
4313
  </td>
4542
4314
  <td>
4543
4315
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -4565,7 +4337,7 @@ multiple locales.</p>
4565
4337
  </span> <span class='comment'>#
4566
4338
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
4567
4339
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4568
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
4340
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
4569
4341
  <span class='kw'>end</span>
4570
4342
 
4571
4343
  <span class='comment'># Sets the `title` attribute.
@@ -4573,7 +4345,7 @@ multiple locales.</p>
4573
4345
  </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.
4574
4346
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4575
4347
  </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>
4576
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
4348
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
4577
4349
  <span class='kw'>end</span>
4578
4350
 
4579
4351
  <span class='comment'># Sets the `summary` attribute.
@@ -4581,7 +4353,7 @@ multiple locales.</p>
4581
4353
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
4582
4354
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4583
4355
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
4584
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4356
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4585
4357
  <span class='kw'>end</span>
4586
4358
 
4587
4359
  <span class='comment'># Sets the `body` attribute.
@@ -4596,7 +4368,7 @@ multiple locales.</p>
4596
4368
  </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.
4597
4369
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
4598
4370
  </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>
4599
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
4371
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
4600
4372
  <span class='kw'>end</span>
4601
4373
 
4602
4374
  <span class='comment'># Sets the `more` attribute.
@@ -4604,7 +4376,7 @@ multiple locales.</p>
4604
4376
  </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.
4605
4377
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
4606
4378
  </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>
4607
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
4379
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
4608
4380
  <span class='kw'>end</span>
4609
4381
 
4610
4382
  <span class='comment'># Sets the `author` attribute.
@@ -4614,8 +4386,8 @@ multiple locales.</p>
4614
4386
  <span class='ivar'>@author</span> <span class='op'>=</span>
4615
4387
  <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>
4616
4388
  <span class='id identifier rubyid_new_author'>new_author</span>
4617
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
4618
- <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='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='rparen'>)</span>
4389
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
4390
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
4619
4391
  <span class='kw'>else</span>
4620
4392
  <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>
4621
4393
  <span class='kw'>end</span>
@@ -4639,15 +4411,44 @@ multiple locales.</p>
4639
4411
  </span> <span class='comment'>#
4640
4412
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
4641
4413
  </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>
4642
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
4414
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
4643
4415
  <span class='kw'>end</span>
4644
4416
 
4645
- <span class='id identifier rubyid_private'>private</span>
4417
+ <span class='comment'># Assigns metadata to a content
4418
+ </span> <span class='comment'>#
4419
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
4420
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
4421
+ </span> <span class='comment'># @return [Content] The content with metadata.
4422
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
4423
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
4424
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
4425
+ <span class='kw'>end</span>
4426
+
4427
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
4428
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
4429
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
4430
+ <span class='kw'>end</span>
4431
+
4432
+ <span class='comment'># Extracts locales from metadata.
4433
+ </span> <span class='comment'>#
4434
+ </span> <span class='comment'># @param locales [String] The list of locales.
4435
+ </span> <span class='comment'># @return [Array] The locales.
4436
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4437
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
4438
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4439
+ <span class='kw'>end</span>
4646
4440
 
4647
- <span class='comment'># Extracts a date and time from a value.
4441
+ <span class='comment'># Normalizes locales for further usage.
4648
4442
  </span> <span class='comment'>#
4649
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4650
- </span> <span class='comment'># @return [DateTime] The extracted value.
4443
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
4444
+ </span> <span class='comment'># @return [Array] The normalized locales.
4445
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4446
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
4447
+ <span class='kw'>end</span>
4448
+
4449
+ <span class='id identifier rubyid_private'>private</span>
4450
+
4451
+ <span class='comment'># :nodoc:
4651
4452
  </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>
4652
4453
  <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>
4653
4454
  <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>
@@ -4655,10 +4456,7 @@ multiple locales.</p>
4655
4456
  <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>
4656
4457
  <span class='kw'>end</span>
4657
4458
 
4658
- <span class='comment'># Parses a datetime.
4659
- </span> <span class='comment'>#
4660
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4661
- </span> <span class='comment'># @return [DateTime] The extracted value.
4459
+ <span class='comment'># :nodoc:
4662
4460
  </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>
4663
4461
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
4664
4462
  <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>
@@ -4672,19 +4470,13 @@ multiple locales.</p>
4672
4470
  <span class='id identifier rubyid_rv'>rv</span>
4673
4471
  <span class='kw'>end</span>
4674
4472
 
4675
- <span class='comment'># Parses a datetime from a number.
4676
- </span> <span class='comment'>#
4677
- </span> <span class='comment'># @param value [String] The value to parse.
4678
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
4473
+ <span class='comment'># :nodoc:
4679
4474
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4680
4475
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
4681
4476
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
4682
4477
  <span class='kw'>end</span>
4683
4478
 
4684
- <span class='comment'># Parses a datetime from a string.
4685
- </span> <span class='comment'>#
4686
- </span> <span class='comment'># @param value [String] The value to parse.
4687
- </span> <span class='comment'># @return [DateTime] The extracted value.
4479
+ <span class='comment'># :nodoc:
4688
4480
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4689
4481
  <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_string'>ensure_string</span>
4690
4482
 
@@ -4699,53 +4491,15 @@ multiple locales.</p>
4699
4491
  <span class='kw'>end</span>
4700
4492
  <span class='kw'>end</span>
4701
4493
 
4702
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
4703
- </span> <span class='comment'>#
4704
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
4705
- </span> <span class='comment'># @return [Array] The list of tags.
4494
+ <span class='comment'># :nodoc:
4706
4495
  </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>
4707
- <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>
4496
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
4708
4497
  <span class='kw'>end</span>
4709
4498
 
4710
- <span class='comment'># Check if value is an Hash.
4711
- </span> <span class='comment'>#
4712
- </span> <span class='comment'># @param value [Object] The object to check.
4713
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
4499
+ <span class='comment'># :nodoc:
4714
4500
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4715
4501
  <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>
4716
4502
  <span class='kw'>end</span>
4717
-
4718
- <span class='comment'># Assigns metadata to a content
4719
- </span> <span class='comment'>#
4720
- </span> <span class='comment'># @param content [Content] The content to manipulate.
4721
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
4722
- </span> <span class='comment'># @return [Content] The content with metadata.
4723
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
4724
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
4725
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
4726
- <span class='kw'>end</span>
4727
-
4728
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
4729
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
4730
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
4731
- <span class='kw'>end</span>
4732
-
4733
- <span class='comment'># Extracts locales from metadata.
4734
- </span> <span class='comment'>#
4735
- </span> <span class='comment'># @param locales [String] The list of locales.
4736
- </span> <span class='comment'># @return [Array] The locales.
4737
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4738
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
4739
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4740
- <span class='kw'>end</span>
4741
-
4742
- <span class='comment'># Normalizes locales for further usage.
4743
- </span> <span class='comment'>#
4744
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
4745
- </span> <span class='comment'># @return [Array] The normalized locales.
4746
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4747
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
4748
- <span class='kw'>end</span>
4749
4503
  <span class='kw'>end</span></pre>
4750
4504
  </td>
4751
4505
  </tr>
@@ -4982,25 +4736,7 @@ multiple locales.</p>
4982
4736
  219
4983
4737
  220
4984
4738
  221
4985
- 222
4986
- 223
4987
- 224
4988
- 225
4989
- 226
4990
- 227
4991
- 228
4992
- 229
4993
- 230
4994
- 231
4995
- 232
4996
- 233
4997
- 234
4998
- 235
4999
- 236
5000
- 237
5001
- 238
5002
- 239
5003
- 240</pre>
4739
+ 222</pre>
5004
4740
  </td>
5005
4741
  <td>
5006
4742
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 36</span>
@@ -5028,7 +4764,7 @@ multiple locales.</p>
5028
4764
  </span> <span class='comment'>#
5029
4765
  </span> <span class='comment'># @param value [Array] The new value for the attribute. A empty or &quot;*&quot; will be the default value.
5030
4766
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_locales='>locales=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5031
- <span class='ivar'>@locales</span> <span class='op'>=</span> <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_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>
4767
+ <span class='ivar'>@locales</span> <span class='op'>=</span> <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
5032
4768
  <span class='kw'>end</span>
5033
4769
 
5034
4770
  <span class='comment'># Sets the `title` attribute.
@@ -5036,7 +4772,7 @@ multiple locales.</p>
5036
4772
  </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.
5037
4773
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
5038
4774
  </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>
5039
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
4775
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
5040
4776
  <span class='kw'>end</span>
5041
4777
 
5042
4778
  <span class='comment'># Sets the `summary` attribute.
@@ -5044,7 +4780,7 @@ multiple locales.</p>
5044
4780
  </span> <span class='comment'># @param new_summary [String|Hash] The new value for the attribute. If an Hash, keys must be a string with one or locale separated by commas.
5045
4781
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
5046
4782
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_summary='>summary=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span>
5047
- <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</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_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4783
+ <span class='ivar'>@summary</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_summary'>new_summary</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new_summary'>new_summary</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
5048
4784
  <span class='kw'>end</span>
5049
4785
 
5050
4786
  <span class='comment'># Sets the `body` attribute.
@@ -5059,7 +4795,7 @@ multiple locales.</p>
5059
4795
  </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.
5060
4796
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value. Tags can also be comma-separated.
5061
4797
  </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>
5062
- <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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> <span class='op'>:</span> <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>
4798
+ <span class='ivar'>@tags</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_tags'>new_tags</span><span class='rparen'>)</span> <span class='op'>?</span> <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='label'>accesses:</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> <span class='op'>:</span> <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>
5063
4799
  <span class='kw'>end</span>
5064
4800
 
5065
4801
  <span class='comment'># Sets the `more` attribute.
@@ -5067,7 +4803,7 @@ multiple locales.</p>
5067
4803
  </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.
5068
4804
  </span> <span class='comment'># A empty or &quot;*&quot; will be the default value.
5069
4805
  </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>
5070
- <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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>
4806
+ <span class='ivar'>@more</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>sanitizer:</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>
5071
4807
  <span class='kw'>end</span>
5072
4808
 
5073
4809
  <span class='comment'># Sets the `author` attribute.
@@ -5077,8 +4813,8 @@ multiple locales.</p>
5077
4813
  <span class='ivar'>@author</span> <span class='op'>=</span>
5078
4814
  <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>
5079
4815
  <span class='id identifier rubyid_new_author'>new_author</span>
5080
- <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>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>
5081
- <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='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='rparen'>)</span>
4816
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_author'>new_author</span><span class='rparen'>)</span>
4817
+ <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='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='lparen'>(</span><span class='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span><span class='rparen'>)</span>
5082
4818
  <span class='kw'>else</span>
5083
4819
  <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>
5084
4820
  <span class='kw'>end</span>
@@ -5102,15 +4838,44 @@ multiple locales.</p>
5102
4838
  </span> <span class='comment'>#
5103
4839
  </span> <span class='comment'># @param new_metadata [Hash] The new value for the attribute.
5104
4840
  </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>
5105
- <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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> <span class='op'>:</span> <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>
4841
+ <span class='ivar'>@metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_metadata'>new_metadata</span><span class='rparen'>)</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='label'>accesses:</span> <span class='symbol'>:indifferent</span><span class='rparen'>)</span> <span class='op'>:</span> <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>
5106
4842
  <span class='kw'>end</span>
5107
4843
 
5108
- <span class='id identifier rubyid_private'>private</span>
4844
+ <span class='comment'># Assigns metadata to a content
4845
+ </span> <span class='comment'>#
4846
+ </span> <span class='comment'># @param content [Content] The content to manipulate.
4847
+ </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
4848
+ </span> <span class='comment'># @return [Content] The content with metadata.
4849
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
4850
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
4851
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
4852
+ <span class='kw'>end</span>
5109
4853
 
5110
- <span class='comment'># Extracts a date and time from a value.
4854
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
4855
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
4856
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
4857
+ <span class='kw'>end</span>
4858
+
4859
+ <span class='comment'># Extracts locales from metadata.
4860
+ </span> <span class='comment'>#
4861
+ </span> <span class='comment'># @param locales [String] The list of locales.
4862
+ </span> <span class='comment'># @return [Array] The locales.
4863
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4864
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
4865
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4866
+ <span class='kw'>end</span>
4867
+
4868
+ <span class='comment'># Normalizes locales for further usage.
5111
4869
  </span> <span class='comment'>#
5112
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
5113
- </span> <span class='comment'># @return [DateTime] The extracted value.
4870
+ </span> <span class='comment'># @param locales [Array] The locales to normalize.
4871
+ </span> <span class='comment'># @return [Array] The normalized locales.
4872
+ </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4873
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
4874
+ <span class='kw'>end</span>
4875
+
4876
+ <span class='id identifier rubyid_private'>private</span>
4877
+
4878
+ <span class='comment'># :nodoc:
5114
4879
  </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>
5115
4880
  <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>
5116
4881
  <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>
@@ -5118,10 +4883,7 @@ multiple locales.</p>
5118
4883
  <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>
5119
4884
  <span class='kw'>end</span>
5120
4885
 
5121
- <span class='comment'># Parses a datetime.
5122
- </span> <span class='comment'>#
5123
- </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
5124
- </span> <span class='comment'># @return [DateTime] The extracted value.
4886
+ <span class='comment'># :nodoc:
5125
4887
  </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>
5126
4888
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
5127
4889
  <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>
@@ -5135,19 +4897,13 @@ multiple locales.</p>
5135
4897
  <span class='id identifier rubyid_rv'>rv</span>
5136
4898
  <span class='kw'>end</span>
5137
4899
 
5138
- <span class='comment'># Parses a datetime from a number.
5139
- </span> <span class='comment'>#
5140
- </span> <span class='comment'># @param value [String] The value to parse.
5141
- </span> <span class='comment'># @return [Float|Fixnum] The extracted value.
4900
+ <span class='comment'># :nodoc:
5142
4901
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_number'>parse_datetime_number</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5143
4902
  <span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span>
5144
4903
  <span class='id identifier rubyid_number'>number</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_number'>number</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>
5145
4904
  <span class='kw'>end</span>
5146
4905
 
5147
- <span class='comment'># Parses a datetime from a string.
5148
- </span> <span class='comment'>#
5149
- </span> <span class='comment'># @param value [String] The value to parse.
5150
- </span> <span class='comment'># @return [DateTime] The extracted value.
4906
+ <span class='comment'># :nodoc:
5151
4907
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5152
4908
  <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_string'>ensure_string</span>
5153
4909
 
@@ -5162,68 +4918,293 @@ multiple locales.</p>
5162
4918
  <span class='kw'>end</span>
5163
4919
  <span class='kw'>end</span>
5164
4920
 
5165
- <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
5166
- </span> <span class='comment'>#
5167
- </span> <span class='comment'># @param value [String|Array] The string or array to parse.
5168
- </span> <span class='comment'># @return [Array] The list of tags.
4921
+ <span class='comment'># :nodoc:
5169
4922
  </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>
5170
- <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>
4923
+ <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='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</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>
5171
4924
  <span class='kw'>end</span>
5172
4925
 
5173
- <span class='comment'># Check if value is an Hash.
5174
- </span> <span class='comment'>#
5175
- </span> <span class='comment'># @param value [Object] The object to check.
5176
- </span> <span class='comment'># @return [Boolean] `true` if value is an Hash, `false` otherwise
4926
+ <span class='comment'># :nodoc:
5177
4927
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_hash?'>hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5178
4928
  <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>
5179
4929
  <span class='kw'>end</span>
4930
+ <span class='kw'>end</span></pre>
4931
+ </td>
4932
+ </tr>
4933
+ </table>
4934
+ </div>
4935
+
4936
+ </div>
5180
4937
 
5181
- <span class='comment'># Assigns metadata to a content
5182
- </span> <span class='comment'>#
5183
- </span> <span class='comment'># @param content [Content] The content to manipulate.
5184
- </span> <span class='comment'># @param metadata [Hash] The metadata to assign.
5185
- </span> <span class='comment'># @return [Content] The content with metadata.
5186
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
5187
- <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
5188
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
5189
- <span class='kw'>end</span>
5190
4938
 
5191
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
5192
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
5193
- <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
5194
- <span class='kw'>end</span>
4939
+ <div id="class_method_details" class="method_details_list">
4940
+ <h2>Class Method Details</h2>
5195
4941
 
5196
- <span class='comment'># Extracts locales from metadata.
5197
- </span> <span class='comment'>#
5198
- </span> <span class='comment'># @param locales [String] The list of locales.
5199
- </span> <span class='comment'># @return [Array] The locales.
5200
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
5201
- <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
5202
- <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
5203
- <span class='kw'>end</span>
4942
+
4943
+ <div class="method_details first">
4944
+ <h3 class="signature first" id="assign_metadata-class_method">
4945
+
4946
+ + (<tt><span class='object_link'><a href="" title="Mbrao::Content (class)">Content</a></span></tt>) <strong>assign_metadata</strong>(content, metadata)
4947
+
5204
4948
 
5205
- <span class='comment'># Normalizes locales for further usage.
5206
- </span> <span class='comment'>#
5207
- </span> <span class='comment'># @param locales [Array] The locales to normalize.
5208
- </span> <span class='comment'># @return [Array] The normalized locales.
5209
- </span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
5210
- <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
4949
+
4950
+
4951
+
4952
+ </h3><div class="docstring">
4953
+ <div class="discussion">
4954
+ <p>Assigns metadata to a content</p>
4955
+
4956
+
4957
+ </div>
4958
+ </div>
4959
+ <div class="tags">
4960
+ <p class="tag_title">Parameters:</p>
4961
+ <ul class="param">
4962
+
4963
+ <li>
4964
+
4965
+ <span class='name'>content</span>
4966
+
4967
+
4968
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Mbrao::Content (class)">Content</a></span></tt>)</span>
4969
+
4970
+
4971
+
4972
+ &mdash;
4973
+ <div class='inline'><p>The content to manipulate.</p>
4974
+ </div>
4975
+
4976
+ </li>
4977
+
4978
+ <li>
4979
+
4980
+ <span class='name'>metadata</span>
4981
+
4982
+
4983
+ <span class='type'>(<tt>Hash</tt>)</span>
4984
+
4985
+
4986
+
4987
+ &mdash;
4988
+ <div class='inline'><p>The metadata to assign.</p>
4989
+ </div>
4990
+
4991
+ </li>
4992
+
4993
+ </ul>
4994
+
4995
+ <p class="tag_title">Returns:</p>
4996
+ <ul class="return">
4997
+
4998
+ <li>
4999
+
5000
+
5001
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Mbrao::Content (class)">Content</a></span></tt>)</span>
5002
+
5003
+
5004
+
5005
+ &mdash;
5006
+ <div class='inline'><p>The content with metadata.</p>
5007
+ </div>
5008
+
5009
+ </li>
5010
+
5011
+ </ul>
5012
+
5013
+ </div><table class="source_code">
5014
+ <tr>
5015
+ <td>
5016
+ <pre class="lines">
5017
+
5018
+
5019
+ 141
5020
+ 142
5021
+ 143
5022
+ 144
5023
+ 145
5024
+ 146
5025
+ 147
5026
+ 148
5027
+ 149</pre>
5028
+ </td>
5029
+ <td>
5030
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 141</span>
5031
+
5032
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_assign_metadata'>assign_metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='rparen'>)</span>
5033
+ <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</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'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
5034
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span><span class='rparen'>)</span>
5211
5035
  <span class='kw'>end</span>
5036
+
5037
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_author'>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_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:author</span><span class='rparen'>)</span><span class='rparen'>)</span>
5038
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:locales</span><span class='rparen'>)</span><span class='rparen'>)</span>
5039
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span> <span class='op'>=</span> <span class='id identifier rubyid_metadata'>metadata</span>
5212
5040
  <span class='kw'>end</span></pre>
5213
5041
  </td>
5214
5042
  </tr>
5215
5043
  </table>
5216
5044
  </div>
5217
5045
 
5046
+ <div class="method_details ">
5047
+ <h3 class="signature " id="extract_locales-class_method">
5048
+
5049
+ + (<tt>Array</tt>) <strong>extract_locales</strong>(locales)
5050
+
5051
+
5052
+
5053
+
5054
+
5055
+ </h3><div class="docstring">
5056
+ <div class="discussion">
5057
+ <p>Extracts locales from metadata.</p>
5058
+
5059
+
5218
5060
  </div>
5061
+ </div>
5062
+ <div class="tags">
5063
+ <p class="tag_title">Parameters:</p>
5064
+ <ul class="param">
5065
+
5066
+ <li>
5067
+
5068
+ <span class='name'>locales</span>
5069
+
5070
+
5071
+ <span class='type'>(<tt>String</tt>)</span>
5072
+
5073
+
5074
+
5075
+ &mdash;
5076
+ <div class='inline'><p>The list of locales.</p>
5077
+ </div>
5078
+
5079
+ </li>
5080
+
5081
+ </ul>
5082
+
5083
+ <p class="tag_title">Returns:</p>
5084
+ <ul class="return">
5085
+
5086
+ <li>
5087
+
5088
+
5089
+ <span class='type'>(<tt>Array</tt>)</span>
5090
+
5091
+
5092
+
5093
+ &mdash;
5094
+ <div class='inline'><p>The locales.</p>
5095
+ </div>
5096
+
5097
+ </li>
5098
+
5099
+ </ul>
5100
+
5101
+ </div><table class="source_code">
5102
+ <tr>
5103
+ <td>
5104
+ <pre class="lines">
5105
+
5106
+
5107
+ 155
5108
+ 156
5109
+ 157
5110
+ 158</pre>
5111
+ </td>
5112
+ <td>
5113
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 155</span>
5114
+
5115
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extract_locales'>extract_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
5116
+ <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_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='kw'>unless</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
5117
+ <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
5118
+ <span class='kw'>end</span></pre>
5119
+ </td>
5120
+ </tr>
5121
+ </table>
5122
+ </div>
5123
+
5124
+ <div class="method_details ">
5125
+ <h3 class="signature " id="normalize_locales-class_method">
5126
+
5127
+ + (<tt>Array</tt>) <strong>normalize_locales</strong>(locales)
5128
+
5129
+
5130
+
5131
+
5132
+
5133
+ </h3><div class="docstring">
5134
+ <div class="discussion">
5135
+ <p>Normalizes locales for further usage.</p>
5136
+
5137
+
5138
+ </div>
5139
+ </div>
5140
+ <div class="tags">
5141
+ <p class="tag_title">Parameters:</p>
5142
+ <ul class="param">
5143
+
5144
+ <li>
5145
+
5146
+ <span class='name'>locales</span>
5147
+
5148
+
5149
+ <span class='type'>(<tt>Array</tt>)</span>
5150
+
5151
+
5152
+
5153
+ &mdash;
5154
+ <div class='inline'><p>The locales to normalize.</p>
5155
+ </div>
5156
+
5157
+ </li>
5158
+
5159
+ </ul>
5160
+
5161
+ <p class="tag_title">Returns:</p>
5162
+ <ul class="return">
5163
+
5164
+ <li>
5165
+
5166
+
5167
+ <span class='type'>(<tt>Array</tt>)</span>
5168
+
5169
+
5170
+
5171
+ &mdash;
5172
+ <div class='inline'><p>The normalized locales.</p>
5173
+ </div>
5174
+
5175
+ </li>
5176
+
5177
+ </ul>
5178
+
5179
+ </div><table class="source_code">
5180
+ <tr>
5181
+ <td>
5182
+ <pre class="lines">
5183
+
5184
+
5185
+ 164
5186
+ 165
5187
+ 166</pre>
5188
+ </td>
5189
+ <td>
5190
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 164</span>
5219
5191
 
5192
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
5193
+ <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:ensure_string</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
5194
+ <span class='kw'>end</span></pre>
5195
+ </td>
5196
+ </tr>
5197
+ </table>
5198
+ </div>
5199
+
5200
+ </div>
5220
5201
 
5221
5202
  </div>
5222
5203
 
5223
5204
  <div id="footer">
5224
- Generated on Sun May 11 18:17:19 2014 by
5205
+ Generated on Tue Mar 29 12:47:22 2016 by
5225
5206
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
5226
- 0.8.7.4 (ruby-2.1.0).
5207
+ 0.8.7.6 (ruby-2.3.0).
5227
5208
  </div>
5228
5209
 
5229
5210
  </body>