Sha256: 82fce4491ebcc4b21cbc66d8ba745975827e2e31a4f34d45bbc43f17b80f307c
Contents?: true
Size: 571 Bytes
Versions: 149
Compression:
Stored size: 571 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}" end end end end end end
Version data entries
149 entries across 149 versions & 1 rubygems