Sha256: 6eba6a4c56ac20d25e95f3ac438e9c428e6eac307db68b9f38149d15659beb18
Contents?: true
Size: 794 Bytes
Versions: 23
Compression:
Stored size: 794 Bytes
Contents
module AttributesHelper def association?(model, attribute) !!model.reflect_on_association(attribute) end def belongs_to_association?(model, attribute) association_type?(model, attribute, :belongs_to) end def has_one_association?(model, attribute) association_type?(model, attribute, :has_one) end def array?(record, attribute) attribute_class?(record, attribute, Array) end def boolean?(record, attribute) ['false', 'true'].include? record.send(attribute).to_s end private def association_type?(model, attribute, association_type) association?(model, attribute) && model.reflect_on_association(attribute).macro == association_type end def attribute_class?(record, attribute, klass) record.send(attribute).class == klass end end
Version data entries
23 entries across 23 versions & 1 rubygems