Sha256: 7f2acb06c89922390d1ad35a0c91d9347bc3b77a0da4d5ede62ac6e141e89eba
Contents?: true
Size: 1.15 KB
Versions: 9
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Lite module Form module Helpers module Persistence module ClassMethods %i[create save update].each do |method_name| define_method(method_name) do |params = {}| klass = new(params) klass.send(method_name) klass end end end class << self def included(klass) klass.extend(ClassMethods) end end def persisted? false end def create raise Lite::Form::NotImplementedError unless defined?(create_action) return unless valid? run_callbacks(:create) { @result = create_action } end def save raise Lite::Form::NotImplementedError unless defined?(save_action) return unless valid? run_callbacks(:save) { @result = save_action } end def update raise Lite::Form::NotImplementedError unless defined?(update_action) return unless valid? run_callbacks(:update) { @result = update_action } end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems