Sha256: 65d64aca1ba1faa9b385098e2eb28376b6cd520e9cff0f22b3cd677c1fc7ebc4
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
require 'rails_admin/config/fields/types/string' module RailsAdmin module Config module Fields module Types class Enum < RailsAdmin::Config::Fields::Base RailsAdmin::Config::Fields::Types::register(self) register_instance_option(:partial) do :form_enumeration end register_instance_option(:enum_method) do @enum_method ||= bindings[:object].respond_to?("#{name}_enum") ? "#{name}_enum" : name end register_instance_option(:enum) do bindings[:object].send(self.enum_method) end register_instance_option(:pretty_value) do if enum.is_a?(::Hash) enum.reject{|k,v| v.to_s != value.to_s}.keys.first.to_s.presence || value.presence || ' - ' elsif enum.is_a?(::Array) && enum.first.is_a?(::Array) enum.find{|e|e[1].to_s == value.to_s}.try(:first).to_s.presence || value.presence || ' - ' else value.presence || ' - ' end end end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems