module Formtastic::Inputs::Base
Attributes
builder[RW]
method[RW]
object[RW]
object_name[RW]
options[RW]
template[RW]
Public Class Methods
new(builder, template, object, object_name, method, options)
click to toggle source
# File lib/formtastic/inputs/base.rb, line 7 def initialize(builder, template, object, object_name, method, options) @builder = builder @template = template @object = object @object_name = object_name @method = method @options = options.dup # Deprecate :member_label and :member_value, remove v4.0 member_deprecation_message = "passing an Array of label/value pairs like [['Justin', 2], ['Kate', 3]] into :collection directly (consider building the array in your model using Model.pluck)" warn_deprecated_option!(:member_label, member_deprecation_message) warn_deprecated_option!(:member_value, member_deprecation_message) end
Public Instance Methods
removed_option!(old_option_name)
click to toggle source
Usefull for raising an error on previously supported option.
# File lib/formtastic/inputs/base.rb, line 37 def removed_option!(old_option_name) raise ArgumentError, ":#{old_option_name} is no longer available" if options.key?(old_option_name) end
warn_and_correct_option!(old_option_name, new_option_name)
click to toggle source
Usefull for deprecating options.
# File lib/formtastic/inputs/base.rb, line 22 def warn_and_correct_option!(old_option_name, new_option_name) if options.key?(old_option_name) ::ActiveSupport::Deprecation.warn("The :#{old_option_name} option is deprecated in favour of :#{new_option_name} and will be removed from Formtastic in the next version", caller(6)) options[new_option_name] = options.delete(old_option_name) end end
warn_deprecated_option!(old_option_name, instructions)
click to toggle source
Usefull for deprecating options.
# File lib/formtastic/inputs/base.rb, line 30 def warn_deprecated_option!(old_option_name, instructions) if options.key?(old_option_name) ::ActiveSupport::Deprecation.warn("The :#{old_option_name} option is deprecated in favour of `#{instructions}`. :#{old_option_name} will be removed in the next version", caller(6)) end end