Sha256: 9bc1b5a4f429158123dc25be6081ef8c42a05836daf3e6ea12481f9ac46b92d9

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

module Id
  module Form
    class ActiveModelForm
      include ActiveModel::Validations
      include ActiveModel::Conversion
      extend  ActiveModel::Naming

      def self.i18n_scope
        :id
      end

      def initialize(model)
        @model = model
      end

      def persisted?
        false
      end

      def to_model
        self
      end

      def to_partial_path
        model.respond_to?(:to_partial_path) ? model.to_partial_path : super
      end

      private

      def method_missing(name, *args, &block)
        model.send(name, *args, &block)
      end

      def memoize(f, &b)
        instance_variable_get("@#{f}") || instance_variable_set("@#{f}", b.call)
      end

      attr_reader :model
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
id-0.0.12 lib/id/form/active_model_form.rb