Skip to content

Commit 19f1b40

Browse files
committed
Rename define_field_type --> field_type, define_field_option --> field_option
1 parent 8715a66 commit 19f1b40

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

docs/reference/fields.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ You may optionally declare a mapping for the new field type in an initializer:
922922
# in /config/initializers/mongoid_custom_fields.rb
923923

924924
Mongoid.configure do |config|
925-
config.define_field_type :point, Point
925+
config.field_type :point, Point
926926
end
927927

928928

@@ -1022,7 +1022,7 @@ specifiying its handler function as a block:
10221022
# in /config/initializers/mongoid_custom_fields.rb
10231023

10241024
Mongoid.configure do |config|
1025-
config.define_field_option :required do |model, field, value|
1025+
config.field_option :required do |model, field, value|
10261026
model.validates_presence_of field.name if value
10271027
end
10281028
end

docs/release-notes/mongoid-8.0.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ Mongoid 8.0 adds the ability to define custom ``field :type`` Symbol values as f
325325
# in /config/initializers/mongoid.rb
326326

327327
Mongoid.configure do |config|
328-
config.define_field_type :point, Point
328+
config.field_type :point, Point
329329
end
330330

331331
Refer to the :ref:`docs <http://docs.mongodb.org/manual/reference/fields/#custom-field-types>` for details.
@@ -341,7 +341,7 @@ Mongoid 8.0 adds the ability to define custom ``field`` options as follows:
341341
# in /config/initializers/mongoid.rb
342342

343343
Mongoid.configure do |config|
344-
config.define_field_option :required do |model, field, value|
344+
config.field_option :required do |model, field, value|
345345
model.validates_presence_of field.name if value
346346
end
347347
end

lib/config/locales/en.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ en:
190190
valid options for the field. These are currently: %{valid}. If you
191191
meant to define a custom field option, please do so first as follows:\n\n
192192
\_\_Mongoid.configure do |config|\n
193-
\_\_\_\_config.define_field_option :%{option} do |model, field, value|\n
193+
\_\_\_\_config.field_option :%{option} do |model, field, value|\n
194194
\_\_\_\_\_\_# Your logic here...\n
195195
\_\_\_\_end\n
196196
\_\_end\n
@@ -602,7 +602,7 @@ en:
602602
resolution: "Please provide a known type value for the field. If you
603603
meant to define a custom field type, please do so first as follows:\n\n
604604
\_\_Mongoid.configure do |config|\n
605-
\_\_\_\_config.define_field_type %{type_inspection}, YourTypeClass
605+
\_\_\_\_config.field_type %{type_inspection}, YourTypeClass
606606
\_\_end\n
607607
\_\_class %{klass}\n
608608
\_\_\_\_include Mongoid::Document\n

lib/mongoid/config.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,15 @@ def running_with_passenger?
318318
#
319319
# @example
320320
# Mongoid.configure do |config|
321-
# config.define_field_type :point, Point
321+
# config.field_type :point, Point
322322
# end
323323
#
324324
# @param [ Symbol | String ] type_name The identifier of the
325325
# defined type. This identifier may be accessible as either a
326326
# Symbol or a String regardless of the type passed to this method.
327327
# @param [ Module ] klass the class of the defined type, which must
328328
# include mongoize, demongoize, and evolve methods.
329-
def define_field_type(type_name, klass)
329+
def field_type(type_name, klass)
330330
Mongoid::Fields::FieldTypes.define_type(type_name, klass)
331331
end
332332

@@ -339,15 +339,15 @@ def define_field_type(type_name, klass)
339339
#
340340
# @example
341341
# Mongoid.configure do |config|
342-
# config.define_field_option :required do |model, field, value|
342+
# config.field_option :required do |model, field, value|
343343
# model.validates_presence_of field.name if value
344344
# end
345345
# end
346346
#
347347
# @param [ Symbol ] option_name the option name to match against
348348
# @param [ Proc ] block the handler to execute when the option is
349349
# provided.
350-
def define_field_option(option_name, &block)
350+
def field_option(option_name, &block)
351351
Mongoid::Fields.option(option_name, &block)
352352
end
353353

spec/mongoid/config_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ def self.logger
815815
end
816816
end
817817

818-
context '#define_field_type' do
818+
context '#field_type' do
819819
around do |example|
820820
klass = Mongoid::Fields::FieldTypes
821821
klass.instance_variable_set(:@mapping, klass::DEFAULT_MAPPING.dup)
@@ -825,29 +825,29 @@ def self.logger
825825

826826
it 'can define a custom type' do
827827
Mongoid.configure do |config|
828-
config.define_field_type :my_type, Integer
828+
config.field_type :my_type, Integer
829829
end
830830

831831
expect(Mongoid::Fields::FieldTypes.get(:my_type)).to eq Integer
832832
end
833833

834834
it 'can override and existing type' do
835835
Mongoid.configure do |config|
836-
config.define_field_type :integer, String
836+
config.field_type :integer, String
837837
end
838838

839839
expect(Mongoid::Fields::FieldTypes.get(:integer)).to eq String
840840
end
841841
end
842842

843-
context '#define_field_option method' do
843+
context '#field_option method' do
844844
after do
845845
Mongoid::Fields.instance_variable_set(:@options, {})
846846
end
847847

848848
it 'can define a custom field option' do
849849
Mongoid.configure do |config|
850-
config.define_field_option :my_required do |model, field, value|
850+
config.field_option :my_required do |model, field, value|
851851
model.validates_presence_of field.name if value
852852
end
853853
end

0 commit comments

Comments
 (0)