Class | Fleximage::ImageProxy |
In: |
lib/fleximage/image_proxy.rb
|
Parent: | Object |
An instance of this class is yielded when Model#operate is called. It enables image operators to be called to transform the image. You should never need to directly deal with this class. You simply call image operators on this object when inside an Model#operate block
@photo.operate do |image| image.resize '640x480' end
In this example, image is an instance of ImageProxy
image | [RW] | The image to be manipulated by operators. |
A call to an unknown method will look for an Operator by that method‘s name. If it finds one, it will execute that operator, otherwise it will simply call super for the default method missing behavior.
# File lib/fleximage/image_proxy.rb, line 29 29: def method_missing(method_name, *args) 30: # Find the operator class 31: operator_class = "Fleximage::Operator::#{method_name.to_s.camelcase}".constantize 32: 33: # Execute the operator 34: @image = operator_class.new(self, @image, @model).execute(*args) 35: 36: rescue NameError => e 37: if e.to_s =~ /uninitialized constant Fleximage::Operator::#{method_name.to_s.camelcase}/ 38: raise OepratorNotFound, "No correspoding operator found for the method \"#{method_name}\"" 39: else 40: raise e 41: end 42: end