Sha256: d489887da3dfffbe0fd82fedd890767d62367bcafe1159e550adb32cc36ce317
Contents?: true
Size: 974 Bytes
Versions: 7
Compression:
Stored size: 974 Bytes
Contents
require "disposable/twin/composition" module Reform::Form::Composition # Automatically creates a Composition object for you when initializing the form. def self.included(base) base.class_eval do # extend Reform::Form::ActiveModel::ClassMethods # ::model. extend ClassMethods include Disposable::Twin::Composition end end module ClassMethods # Same as ActiveModel::model but allows you to define the main model in the composition # using +:on+. # # class CoverSongForm < Reform::Form # model :song, on: :cover_song def model(main_model, options={}) super composition_model = options[:on] || main_model # FIXME: this should just delegate to :model as in FB, and the comp would take care of it internally. [:persisted?, :to_key, :to_param].each do |method| define_method method do model[composition_model].send(method) end end self end end end
Version data entries
7 entries across 7 versions & 1 rubygems