Class: Mongoid::Field

Inherits:
Object show all
Defined in:
lib/mongoid/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Field

Create the new field with a name and optional additional options. Valid options are :default

Options:

name: The name of the field as a Symbol. options: A Hash of options for the field.

Example:

Field.new(:score, :default => 0)



19
20
21
22
# File 'lib/mongoid/field.rb', line 19

def initialize(name, options = {})
  @name = name
  @default = options[:default]
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



4
5
6
# File 'lib/mongoid/field.rb', line 4

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/mongoid/field.rb', line 4

def name
  @name
end