Sha256: a65f911a50e819e6a24b84797d11b5734fd8e8911e9149e00f54d9b8d256312d

Contents?: true

Size: 297 Bytes

Versions: 9

Compression:

Stored size: 297 Bytes

Contents

module Refinery
  class TranslatedFieldPresenter
    def initialize(record)
      @record = record
    end

    def call(field)
      record.send(field).presence ||
        record.translations.detect {|t| t.send(field).present?}.send(field)
    end

    private
    attr_accessor :record
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
refinerycms-core-4.0.3 app/presenters/refinery/translated_field_presenter.rb
refinerycms-core-4.0.2 app/presenters/refinery/translated_field_presenter.rb
refinerycms-core-4.0.1 app/presenters/refinery/translated_field_presenter.rb
refinerycms-core-3.0.6 app/presenters/refinery/translated_field_presenter.rb
refinerycms-core-4.0.0 app/presenters/refinery/translated_field_presenter.rb
refinerycms-core-3.0.5 app/presenters/refinery/translated_field_presenter.rb
refinerycms-core-3.0.4 app/presenters/refinery/translated_field_presenter.rb
refinerycms-core-3.0.3 app/presenters/refinery/translated_field_presenter.rb
refinerycms-core-3.0.2 app/presenters/refinery/translated_field_presenter.rb