Sha256: 0705faf7ada642fdbb7cc1d045d236266b2cd980a17325889185d941de9ca7b1

Contents?: true

Size: 520 Bytes

Versions: 2

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

module PageMeta
  class Translator
    attr_reader :scope, :naming, :options

    def initialize(scope, naming, options = {})
      @scope = scope
      @naming = naming
      @options = options
    end

    def to_s
      return "" if simple.blank?
      I18n.t("page_meta.#{scope}.base", value: simple, default: simple)
    end

    def simple
      I18n.t(
        "page_meta.#{scope}.#{naming.controller}.#{naming.action}",
        options.merge(default: "")
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page_meta-0.1.3 lib/page_meta/translator.rb
page_meta-0.1.2 lib/page_meta/translator.rb