Class: ImageLoader
- Inherits:
-
Object
- Object
- ImageLoader
- 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
-
#image_class ⇒ Object
readonly
Returns the value of attribute image_class.
Delegated Instance Attributes collapse
-
#find ⇒ Object
Alias for @image_class#find.
Instance Method Summary collapse
-
#initialize ⇒ ImageLoader
constructor
A new instance of ImageLoader.
Constructor Details
#initialize ⇒ ImageLoader
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_class ⇒ Object (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
#find ⇒ Object
Alias for @image_class#find
18 |
# File 'app/models/image_loader.rb', line 18 delegate :find, to: :@image_class |