Sha256: 66d4369aea427fbdd87811a7bdbad0e09f67bcf4a02d8f56ec4b3b00f505eeae

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 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) unless value.nil?
          end

          def parse_value(value)
            value.present? ? (SafeYAML.load(value) || nil) : nil
          end

          def parse_input(params)
            params[name] = parse_value(params[name]) if params[name].is_a?(::String)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_admin-0.8.1 lib/rails_admin/config/fields/types/serialized.rb