I have a simple class used to store configuration for default images:
class DefaultImages
class <<self
attr_accessor :format
attr_accessor :directory
attr_accessor :width
attr_accessor :height
end
def self.setup
yield self
end
end
I populate it in an initializer:
DefaultImages.setup do |config|
config.format = :png
config.directory = 'default'
config.width = 2161
config.height = 1441
end
If I log the attributes here in the accessor, all are populated:
Rails.logger.warn "Default Image Format: #{DefaultImages.format}" # png
However, when I access the attributes of DefaultImages later in the application, they are all nil. The same is true if I access its attributes from the console.
There is no other code that touches DefaultImages other than to access its attributes after the initializer has run. I have obviously restarted the server etc.
Why might its attributes be nil?