Sha256: cccb6988b064e7612d46ad9da11d98e3bff615272e261bf955386dafd1bb12e0
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Granite module Form module Model module Associations class ReferencesAny < Base def scope(source = read_source) reflection.persistence_adapter.scope(owner, source) end private def read_source attribute.read_before_type_cast end def write_source(value) attribute.write_value value end def attribute @attribute ||= owner.attribute(reflection.reference_key) end def build_object(attributes) reflection.persistence_adapter.build(attributes) end def persist_object(object, **options) reflection.persistence_adapter.persist(object, **options) end def matches_type?(object) object.is_a?(reflection.persistence_adapter.data_type) end def raise_type_mismatch(object) raise AssociationTypeMismatch.new(reflection.persistence_adapter.data_type, object.class) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
granite-form-0.6.0 | lib/granite/form/model/associations/references_any.rb |