module AdminIt::MongoidData::Resource
Constants
- NONFILTER_TYPES
- TYPE_MAPPING
Protected Instance Methods
default_fields(&block)
click to toggle source
# File lib/admin_it/data/mongoid/resource.rb, line 30 def default_fields(&block) enum = Enumerator.new do |yielder| entity_class.fields.each do |name, field| name = name.to_sym opts = { type: TYPE_MAPPING[field.options[:type]] } if name == :_id name = :id opts[:visible] = false opts[:writable] = false end yielder << AdminIt::Field.create(name, entity_class, opts) end relations = entity_class.relations relations.merge!(entity_class.embedded_relations) relations.each do |name, rel| name = name.to_sym opts = { type: :relation } field = AdminIt::Field.create(name, entity_class, opts) field.assoc = rel yielder << field end end block_given? ? enum.each(&block) : enum end
default_filters()
click to toggle source
# File lib/admin_it/data/mongoid/resource.rb, line 55 def default_filters enum = Enumerator.new do |yielder| fields.each do |field| next if NONFILTER_TYPES.include?(field.type) name = "#{field.field_name}_value" yielder << AdminIt::ValueFilter.create(name, self, field) end end block_given? ? enum.each(&block) : enum end