Sha256: 42433ab415875cdf45205d5f08d51c125e5778e2c5e6fcedacef7a5d5046c163

Contents?: true

Size: 785 Bytes

Versions: 106

Compression:

Stored size: 785 Bytes

Contents

module Fields::DateSupport
  extend ActiveSupport::Concern

  def assign_date(strong_params, attribute)
    deprecator = ActiveSupport::Deprecation.new("2.0", "BulletTrain::Fields")
    deprecator.deprecation_warning(
      "assign_date",
      "Please assign an ISO8601 date string as field value instead and remove all assign_date assignments,
      see https://ruby-doc.org/3.2.2/exts/date/Date.html"
    )
    attribute = attribute.to_s
    if strong_params.dig(attribute).present?
      begin
        strong_params[attribute] = Date.iso8601(strong_params[attribute])
      rescue ArgumentError
        parsed_value = Chronic.parse(strong_params[attribute])
        return nil unless parsed_value
        strong_params[attribute] = parsed_value.to_date
      end
    end
  end
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
bullet_train-fields-1.11.0 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.10.0 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.9.0 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.8.5 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.8.4 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.8.3 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.8.2 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.8.1 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.8.0 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.23 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.22 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.21 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.20 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.19 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.18 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.17 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.16 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.15 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.14 app/controllers/concerns/fields/date_support.rb
bullet_train-fields-1.7.13 app/controllers/concerns/fields/date_support.rb