Sha256: c4b8fbd948a90f03990299586a56acf7bda306a6c04b02d1b040a8b16b65718d

Contents?: true

Size: 979 Bytes

Versions: 5

Compression:

Stored size: 979 Bytes

Contents

# frozen_string_literal: true

module Lite
  module Form
    class Base

      extend ActiveModel::Callbacks
      extend ActiveModel::Naming
      extend ActiveModel::Translation

      include ActiveModel::Model
      include ActiveModel::Attributes
      include ActiveModel::Dirty
      include ActiveModel::Serialization
      include Lite::Form::Helpers::Errors
      include Lite::Form::Helpers::Persistence
      include Lite::Form::Helpers::Propagation

      define_model_callbacks :initialize
      define_model_callbacks :create
      define_model_callbacks :save
      define_model_callbacks :update

      class << self

        def model_name
          klass = name.gsub('Form', '')
          klass = Object.const_get(klass)
          klass.model_name
        rescue StandardError
          super
        end

      end

      attr_reader :result

      def initialize(params = {})
        run_callbacks(:initialize) { super(params) }
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lite-form-1.0.4 lib/lite/form/base.rb
lite-form-1.0.3 lib/lite/form/base.rb
lite-form-1.0.2 lib/lite/form/base.rb
lite-form-1.0.1 lib/lite/form/base.rb
lite-form-1.0.0 lib/lite/form/base.rb