Sha256: 5dfb96038d08bbb88b5a63aec24f67b0ae4b009cdf3d606ee05ab3cc5d594e45

Contents?: true

Size: 643 Bytes

Versions: 3

Compression:

Stored size: 643 Bytes

Contents

require 'rails_admin/config/fields/types/text'

module RailsAdmin
  module Config
    module Fields
      module Types
        class Serialized < RailsAdmin::Config::Fields::Types::Text
          # Register field type for the type loader
          RailsAdmin::Config::Fields::Types::register(self)

          register_instance_option :formatted_value do
            YAML.dump(value)
          end

          def parse_input(params)
            if params[name].is_a?(::String)
              params[name] = (params[name].blank? ? nil : (YAML.safe_load(params[name]) || nil))
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_admin-0.4.9 lib/rails_admin/config/fields/types/serialized.rb
rails_admin-0.4.8 lib/rails_admin/config/fields/types/serialized.rb
rails_admin-0.4.7 lib/rails_admin/config/fields/types/serialized.rb