Sha256: c2b72bbc1efe2fd5cb6a549ca481721a7be75a6e1a25edfc4ae971691b1ed9ec
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'active_form_model/version' require 'active_support/concern' module ActiveFormModel class Error < StandardError; end extend ActiveSupport::Concern included do prepend Included end module Included def initialize(attrs = {}) permitted_attrs = permit_attrs(attrs) super(permitted_attrs) end end module ClassMethods delegate :sti_name, to: :superclass delegate :human_attribute_name, to: :superclass # delegate :name, to: :superclass def permit(*args) @_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 def permit_attrs(attrs) attrs.respond_to?(:permit) ? attrs.send(:permit, self.class._permitted_args) : attrs end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_form_model-0.3.0 | lib/active_form_model.rb |