Sha256: 088fdd7ef8ff6ab818489925090a971be4d14da6e45b4f4f068fdf6fdc707ee8

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 Bytes

Contents

require 'act_form/version'
require 'act_form/model'
require 'act_form/runnable'

module ActForm
  class Base
    include Model
  end

  class RecordForm < Base
    attr_reader :record
    def initialize(record, **attrs)
      @record = record
      @extract_attrs = @record.attributes.extract! *self.class.attribute_set.map(&:name).map(&:to_s)
      super(@extract_attrs.merge(attrs))
    end

    def save
      if valid?
        sync(@record)
        @persisted = @record.save
      else
        false
      end
    end
  end

  class Command < Base
    include Runnable
    private_class_method :new
  end
end

require 'act_form/railtie' if defined?(Rails)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
act_form-0.1.0 lib/act_form.rb