Class: Rails::Schema::Extractor::Mongoid::ColumnReader
- Inherits:
-
Object
- Object
- Rails::Schema::Extractor::Mongoid::ColumnReader
- Defined in:
- lib/rails/schema/extractor/mongoid/column_reader.rb
Constant Summary collapse
- TYPE_MAP =
{ "String" => "string", "Integer" => "integer", "Float" => "float", "BigDecimal" => "decimal", "Date" => "date", "Time" => "datetime", "DateTime" => "datetime", "Array" => "array", "Hash" => "hash", "Regexp" => "regexp", "Symbol" => "symbol", "Range" => "range", "BSON::ObjectId" => "object_id", "Mongoid::Boolean" => "boolean", "TrueClass" => "boolean", "FalseClass" => "boolean" }.freeze
Instance Method Summary collapse
Instance Method Details
#read(model) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails/schema/extractor/mongoid/column_reader.rb', line 27 def read(model) model.fields.map do |name, field| { name: name, type: map_type(field.type), nullable: !required_field?(model, name), primary: name == "_id", default: format_default(field.default_val) } end rescue StandardError => e warn "[rails-schema] Could not read Mongoid fields for #{model.name}: #{e.class}: #{e.}" [] end |