Sha256: 57b827a6d9009f291b9ba8f90f9f6396ea7f64399e16b864ce8bf5d08755a143

Contents?: true

Size: 717 Bytes

Versions: 4

Compression:

Stored size: 717 Bytes

Contents

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

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

          register_instance_option :formatted_value do
            value.present? ? JSON.pretty_generate(value) : nil
          end

          def parse_input(params)
            return unless params[name].is_a?(::String)
            params[name] = (params[name].blank? ? nil : JSON.parse(params[name]))
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rails_admin-0.7.0/lib/rails_admin/config/fields/types/json.rb
rails_admin-0.7.0 lib/rails_admin/config/fields/types/json.rb
rails_admin-0.6.8 lib/rails_admin/config/fields/types/json.rb
rails_admin-0.6.7 lib/rails_admin/config/fields/types/json.rb