Module: Spamtrap::FormBuilderMutation

Includes:
Crypto
Included in:
ActionView::Helpers::FormBuilder
Defined in:
lib/spamtrap/helper.rb

Constant Summary collapse

MUTABLE_FIELDS =
%i[
  text_field email_field password_field number_field url_field telephone_field
  text_area check_box hidden_field file_field date_field time_field
  datetime_local_field month_field week_field search_field color_field
  range_field select collection_select grouped_collection_select label
].freeze

Constants included from Crypto

Crypto::CIPHER, Crypto::KEY_LEN, Crypto::NONCE_LEN, Crypto::TAG_LEN

Instance Method Summary collapse

Instance Method Details

#fields_for(record_name, record_object = nil, fields_options = {}, &block) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/spamtrap/helper.rb', line 82

def fields_for(record_name, record_object = nil, fields_options = {}, &block)
  if @spamtrap_salt
    if record_object.is_a?(Hash) && record_object.extractable_options?
      record_object = record_object.merge(spamtrap_salt: @spamtrap_salt)
    else
      fields_options = fields_options.merge(spamtrap_salt: @spamtrap_salt)
    end
  end
  super(record_name, record_object, fields_options, &block)
end

#initialize(object_name, object, template, options) ⇒ Object



77
78
79
80
# File 'lib/spamtrap/helper.rb', line 77

def initialize(object_name, object, template, options)
  super
  @spamtrap_salt = options[:spamtrap_salt] if options[:spamtrap_salt]
end