Sha256: f4954453e398edcba8e00faee0c929dc9cfb4bcdb2ecbd455a4ab4ef5063631e
Contents?: true
Size: 973 Bytes
Versions: 8
Compression:
Stored size: 973 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. %i[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
8 entries across 8 versions & 1 rubygems