Module: Ikra::Symbolic::ArrayCommand::ClassMethods

Defined in:
lib/types/types/array_command_type.rb

Defined Under Namespace

Classes: NormalCache, WeakCache

Instance Method Summary collapse

Instance Method Details

#new(*args, **kwargs, &block) ⇒ Object

Ensure that ArrayCommands are singletons. Otherwise, we have a problem, because two equal commands can have different class IDs.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/types/types/array_command_type.rb', line 78

def new(*args, **kwargs, &block)
    if @cache == nil
        @cache = WeakCache.new
    end

    new_command = super

    if @cache.include?(new_command)
        return @cache.get_value(new_command)
    else
        @cache.add_value(new_command)
        return new_command
    end
end