Sha256: e1957acdb470abfaead6617606a9130367403b871ac069ffe5f07f0ae5ce2f03

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 Bytes

Contents

module SoMeta
  module Helper
    def so_meta(name, scope = nil)
      interpolation_data = instance_variable_get("@so_meta_#{name}_interpolation") || {}

      request_key = "so_meta.#{controller_path.gsub(/\//, "_")}.#{action_name}"

      if scope.present?
        begin
          return I18n.translate!("#{request_key}.#{scope}.#{name}")
        rescue I18n::MissingTranslationData
          nil
        end
      end

      t("#{request_key}.#{name}", interpolation_data.merge(default: t("so_meta.defaults.#{name}")))
    end

    def so_meta_interpolation(name, hash)
      instance_variable_set("@so_meta_#{name}_interpolation", hash)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
so_meta-0.7 lib/so_meta/helper.rb