Sha256: ce273db8b4b02b393c904e14b0fb23e365c65ee85dc6aa119e90279c56c40186

Contents?: true

Size: 581 Bytes

Versions: 3

Compression:

Stored size: 581 Bytes

Contents

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types/enum'

RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
  model = parent.abstract_model.model
  method_name = "#{properties.name}_enum"

  # NOTICE: _method_name could be `to_enum` and this method defined in Object.
  if !Object.respond_to?(method_name) && \
     (model.respond_to?(method_name) || \
         model.method_defined?(method_name))
    fields << RailsAdmin::Config::Fields::Types::Enum.new(parent, properties.name, properties)
    true
  else
    false
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_admin-0.6.8 lib/rails_admin/config/fields/factories/enum.rb
rails_admin-0.6.7 lib/rails_admin/config/fields/factories/enum.rb
rails_admin-0.6.6 lib/rails_admin/config/fields/factories/enum.rb