Class: Mongify::Mongoid::Model::Field
- Inherits:
-
Object
- Object
- Mongify::Mongoid::Model::Field
- Defined in:
- lib/mongify/mongoid/model/field.rb
Overview
Field for a Mongoid Model
Constant Summary collapse
- ACCEPTED_TYPES =
List of accepted types
[ "Array", "BigDecimal", "Decimal", "Boolean", "Date", "DateTime", "Float", "Hash", "Integer", "Moped::BSON::ObjectId", "Moped::BSON::Binary", "Range", "Regexp", "String", "Symbol", "Time", "TimeWithZone" ]
- TRANSLATION_TYPES =
Hash of translations for different types
{ array: "Array", bigdecimal: "BigDecimal", decimal: "String", boolean: "Boolean", date: "Date", datetime: "DateTime", float: "Float", hash: "Hash", integer: "Integer", objectid: "Moped::BSON::ObjectId", binary: "Moped::BSON::Binary", range: "Range", regexp: "Regexp", string: "String", symbol: "Symbol", time: "Time", text: "String", timewithzone: "TimeWithZone" }
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type, options = {}) ⇒ Field
constructor
A new instance of Field.
Constructor Details
#initialize(name, type, options = {}) ⇒ Field
Returns a new instance of Field.
53 54 55 56 57 58 |
# File 'lib/mongify/mongoid/model/field.rb', line 53 def initialize(name, type, ={}) @name = name @options = @type = translate_type(type) check_field_type(@type) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
51 52 53 |
# File 'lib/mongify/mongoid/model/field.rb', line 51 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
51 52 53 |
# File 'lib/mongify/mongoid/model/field.rb', line 51 def @options end |
#type ⇒ Object
Returns the value of attribute type.
51 52 53 |
# File 'lib/mongify/mongoid/model/field.rb', line 51 def type @type end |