Sha256: 4ff18cfd01f8d0ec9c4a8d0eb29a31ae73f65aa90bca9126abbaf00a4664af3c

Contents?: true

Size: 676 Bytes

Versions: 4

Compression:

Stored size: 676 Bytes

Contents

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

module Administrate
  module Field
    module Mobility
      class Text < 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 to_partial_path
          "/fields/mobility/text/#{page}"
        end

        private

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
administrate-field-mobility-text-0.0.2 lib/administrate/field/mobility/text.rb
administrate-field-mobility-0.0.2 administrate-field-mobility-text/lib/administrate/field/mobility/text.rb
administrate-field-mobility-text-0.0.1 lib/administrate/field/mobility/text.rb
administrate-field-mobility-0.0.1 administrate-field-mobility-text/lib/administrate/field/mobility/text.rb