Sha256: e6846b9d96deea3d9005d4a0d9764a1007e761e92d4e76158e0c77a75e5d0f3a

Contents?: true

Size: 797 Bytes

Versions: 2

Compression:

Stored size: 797 Bytes

Contents

require "administrate/field/base"
require "rails"

module Administrate
  module Field
    module Globalize
      class String < Administrate::Field::Base
        class Engine < ::Rails::Engine
        end

        def self.permitted_attribute(attr, _options = nil)
          I18n.available_locales.map do |locale|
            "#{attr}_#{locale}".downcase.underscore
          end
        end

        def truncate
          data.to_s[0...truncation_length]
        end

        def self.searchable?
          true
        end

        def self.translation?
          true
        end

        def to_partial_path
          "/fields/globalize/string/#{page}"
        end

        private

        def truncation_length
          options.fetch(:truncate, 50)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
administrate-field-globalize-0.0.1.alpha3 administrate-field-globalize-string/lib/administrate/field/globalize/string.rb
administrate-field-globalize-string-0.0.1.alpha3 lib/administrate/field/globalize/string.rb