Class: SchemaSerializer::Constantizer

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_serializer/constantizer.rb

Class Method Summary collapse

Class Method Details

.find(name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/schema_serializer/constantizer.rb', line 4

def find(name)
  return cached_serializers.fetch(name) if cached_serializers.has_key?(name)
  return nil                            if non_existent_serializers.include?(name)

  klass = name.safe_constantize
  if klass.present?
    cached_serializers[name] = klass
    return klass
  end

  non_existent_serializers << name
  nil
end

.refresh!Object



18
19
20
21
# File 'lib/schema_serializer/constantizer.rb', line 18

def refresh!
  @non_existent_serializers = []
  @serializers = {}
end