Class: ImageLoader

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
app/models/image_loader.rb

Overview

Singleton image-record gateway that picks the right backend based on
the environment: in production (or when LOCAL_IMAGE=y is set
locally) it loads from the database via Image.friendly; in dev/test
it talks to the production Heatwave API (Api::Image) so designers
can preview existing assets without seeding the local DB.

Instance Attribute Summary collapse

Delegated Instance Attributes collapse

Instance Method Summary collapse

Constructor Details

#initializeImageLoader

Returns a new instance of ImageLoader.



14
15
16
# File 'app/models/image_loader.rb', line 14

def initialize
  @image_class = Rails.env.production? || ENV['LOCAL_IMAGE'] == 'y' ? Image.friendly : Api::Image
end

Instance Attribute Details

#image_classObject (readonly)

Returns the value of attribute image_class.



12
13
14
# File 'app/models/image_loader.rb', line 12

def image_class
  @image_class
end

Instance Method Details

#findObject

Alias for @image_class#find

Returns:

  • (Object)

    @image_class#find

See Also:



18
# File 'app/models/image_loader.rb', line 18

delegate :find, to: :@image_class