Sha256: ef2b82001542481f5287f106e3f4c9f1c48efbde80b8333059af305d5e5be5ea
Contents?: true
Size: 576 Bytes
Versions: 13
Compression:
Stored size: 576 Bytes
Contents
module Avo module Concerns module ModelClassConstantized extend ActiveSupport::Concern class_methods do attr_reader :model_class # Cast the model class to a constantized version and memoize it like that def model_class=(value) @model_class = case value when Class value when String, Symbol value.to_s.safe_constantize else raise ArgumentError.new "Failed to find a proper model class for #{self.to_s}" end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems