Sha256: e27adfe8ebd74a8524d7ffd8e69e4f105a4b3b4d21123bad110d563f6f24ba79
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
require 'rails_admin/config/fields/types/string' module RailsAdmin module Config module Fields module Types class BsonObjectId < RailsAdmin::Config::Fields::Types::String # Register field type for the type loader RailsAdmin::Config::Fields::Types::register(self) register_instance_option(:label) do label = ((@label ||= {})[::I18n.locale] ||= abstract_model.model.human_attribute_name name) label = "Id" if label == '' label end register_instance_option(:help) do "BSON::ObjectId" end register_instance_option(:read_only) do true end register_instance_option(:sort_reverse?) do serial? end def parse_input(params) begin params[name] = (params[name].blank? ? nil : BSON::ObjectId(params[name])) if params[name].is_a?(::String) rescue BSON::InvalidObjectId end end end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems