diff --git a/app/controllers/api/v1/csp_reports_controller.rb b/app/controllers/api/v1/csp_reports_controller.rb index 1c1ef0a..bc6cfae 100644 --- a/app/controllers/api/v1/csp_reports_controller.rb +++ b/app/controllers/api/v1/csp_reports_controller.rb @@ -12,8 +12,8 @@ module Api # TODO: Aplicar rate_limit def create csp = CspReport.new(csp_report_params.to_h.map do |k, v| - { k.tr('-', '_') => v } - end.inject(&:merge)) + [k.tr('-', '_'), v] + end.to_h) csp.id = SecureRandom.uuid csp.save diff --git a/app/models/metadata_event.rb b/app/models/metadata_event.rb index 89007dd..3213d87 100644 --- a/app/models/metadata_event.rb +++ b/app/models/metadata_event.rb @@ -61,13 +61,13 @@ class MetadataEvent < MetadataTemplate self[:value] = %w[dtstart dtend].map do |dt| time = hash.dig(dt, 'time') - { - dt => { + [ + dt, { 'zone' => hash.dig(dt, 'zone'), 'date' => Date.parse(hash.dig(dt, 'date')).to_s, 'time' => time.blank? ? '00:00' : time } - } - end.inject(:merge) + ] + end.to_h end end diff --git a/app/models/metadata_locales.rb b/app/models/metadata_locales.rb index 6498ed7..8958110 100644 --- a/app/models/metadata_locales.rb +++ b/app/models/metadata_locales.rb @@ -14,11 +14,9 @@ class MetadataLocales < MetadataTemplate # @return { lang: { title: uuid } } def values @values ||= site.locales.map do |locale| - { - locale.to_sym => site.posts(lang: locale).map do |post| - { post.title.value => post.uuid.value } - end.inject(:merge) - } - end.inject(:merge) + [locale.to_sym, site.posts(lang: locale).map do |post| + [post.title.value, post.uuid.value] + end.to_h] + end.to_h end end diff --git a/app/models/metadata_predefined_array.rb b/app/models/metadata_predefined_array.rb index a6e2105..829a8a2 100644 --- a/app/models/metadata_predefined_array.rb +++ b/app/models/metadata_predefined_array.rb @@ -4,7 +4,7 @@ class MetadataPredefinedArray < MetadataArray def values @values ||= layout[:metadata][name]['values'].map do |k, v| - { v[I18n.locale.to_s] => k } - end.inject(&:merge) + [v[I18n.locale.to_s], k] + end.to_h end end diff --git a/app/models/metadata_related_posts.rb b/app/models/metadata_related_posts.rb index e38538a..5148a9f 100644 --- a/app/models/metadata_related_posts.rb +++ b/app/models/metadata_related_posts.rb @@ -4,10 +4,11 @@ # idioma que el actual, para usar con input-map.js class MetadataRelatedPosts < MetadataArray # Genera un Hash de { title | slug => uuid } + # @return [Hash] def values @values ||= posts.map do |p| - { title(p) => p.uuid.value } - end.inject(:merge) + [title(p), p.uuid.value] + end.to_h end # Las relaciones nunca son privadas diff --git a/app/models/post.rb b/app/models/post.rb index c238ece..f43c02e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -205,8 +205,8 @@ class Post < OpenStruct next if template.empty? - { metadata.to_s => template.value } - end.compact.inject(:merge) + [metadata.to_s, template.value] + end.compact.to_h # TODO: Convertir a Metadata? # Asegurarse que haya un layout diff --git a/app/models/site.rb b/app/models/site.rb index daa83c4..38645a3 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -265,10 +265,8 @@ class Site < ApplicationRecord # NoMethodError @layouts_struct ||= Struct.new(*layout_keys, keyword_init: true) @layouts ||= @layouts_struct.new(**data.fetch('layouts', {}).map do |name, metadata| - { name.to_sym => Layout.new(site: self, - name: name.to_sym, - metadata: metadata.with_indifferent_access) } - end.inject(:merge)) + [name.to_sym, Layout.new(site: self, name: name.to_sym, metadata: metadata.with_indifferent_access)] + end.to_h) end def layout_keys