Sha256: 9185b5b06354d34c8fcbb3cdfbb60c4e5c60dc0db4b8f96c5e88341e1479a638
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require 'active_support/deprecation/reporting' module ActiveFormModel module Permittable extend ActiveSupport::Concern included do prepend Prepended end module Prepended def initialize(attrs = {}) permitted_attrs = permit_attrs(attrs) super(permitted_attrs) end end class_methods do def fields(*args) @_permitted_args = args end def permit(*args) ActiveSupport::Deprecation.warn('permit is deprecated in favor of fields') @_permitted_args = args end def _permitted_args @_permitted_args || (superclass.respond_to?(:_permitted_args) && superclass._permitted_args) || [] end end def update(attrs = {}) permitted_attrs = permit_attrs(attrs) super(permitted_attrs) end def update!(attrs = {}) permitted_attrs = permit_attrs(attrs) super(permitted_attrs) end def assign_attributes(attrs = {}) permitted_attrs = permit_attrs(attrs) super(permitted_attrs) end private def permit_attrs(attrs) attrs.respond_to?(:permit) ? attrs.send(:permit, self.class._permitted_args) : attrs end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_form_model-0.4.1 | lib/active_form_model/permittable.rb |