Sha256: b2d5273aa651c1f2a2d17538d705fd96b9565893ac78c3b589ca178c5d132114
Contents?: true
Size: 711 Bytes
Versions: 28
Compression:
Stored size: 711 Bytes
Contents
module Avo module Concerns module ModelClassConstantized extend ActiveSupport::Concern class_methods do # Cast the model class to a constantized version and memoize it like that def model_class=(value) @model_class = value end # Cast the model class to a constantized version def constantized_model_class @constantized_model_class ||= case @model_class when Class @model_class when String, Symbol @model_class.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
28 entries across 28 versions & 1 rubygems