Sha256: e6ccc8ae309d5dc5edfc1bc72080389017ef2c29cd24984855dbf09fcb43ac5a

Contents?: true

Size: 654 Bytes

Versions: 20

Compression:

Stored size: 654 Bytes

Contents

module Spina
  module TranslatedContent
    extend ActiveSupport::Concern
    
    include Spina::AttrJsonMonkeypatch

    included do  
      # Store each locale's content in [locale]_content as an array of parts
      Spina.config.locales.each do |locale|
        attr_json "#{locale}_content".to_sym, AttrJson::Type::SpinaPartsModel.new, array: true, default: -> { [] }
        attr_json_setter_monkeypatch "#{locale}_content".to_sym
        attr_json_accepts_nested_attributes_for "#{locale}_content".to_sym
      end
    end
    
    def find_part(name)
      send("#{I18n.locale}_content").find{|part| part.name.to_s == name.to_s}
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
spina-2.10.0 app/models/concerns/spina/translated_content.rb
spina-2.9.1 app/models/concerns/spina/translated_content.rb
spina-2.9.0 app/models/concerns/spina/translated_content.rb
spina-2.8.1 app/models/concerns/spina/translated_content.rb
spina-2.8.0 app/models/concerns/spina/translated_content.rb
spina-2.7.0 app/models/concerns/spina/translated_content.rb
spina-2.6.2 app/models/concerns/spina/translated_content.rb
spina-2.6.1 app/models/concerns/spina/translated_content.rb
spina-2.6.0 app/models/concerns/spina/translated_content.rb
spina-2.5.0 app/models/concerns/spina/translated_content.rb
spina-2.4.0 app/models/concerns/spina/translated_content.rb
spina-2.3.5 app/models/concerns/spina/translated_content.rb
spina-2.3.4 app/models/concerns/spina/translated_content.rb
spina-2.3.3 app/models/concerns/spina/translated_content.rb
spina-2.3.2 app/models/concerns/spina/translated_content.rb
spina-2.3.1 app/models/concerns/spina/translated_content.rb
spina-2.3.0 app/models/concerns/spina/translated_content.rb
spina-2.2.0 app/models/concerns/spina/translated_content.rb
spina-2.1.1 app/models/concerns/spina/translated_content.rb
spina-2.1.0 app/models/concerns/spina/translated_content.rb