Sha256: e88393decd5dc5699e00b36a42b5a85c7192de189535bbf5707f92ea38db6316

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

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 :commit
      define_model_callbacks :create
      define_model_callbacks :rollback
      define_model_callbacks :save
      define_model_callbacks :update

      attr_reader :result

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

      class << self

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

      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lite-form-1.1.2 lib/lite/form/base.rb
lite-form-1.1.1 lib/lite/form/base.rb
lite-form-1.1.0 lib/lite/form/base.rb
lite-form-1.0.5 lib/lite/form/base.rb