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

Methods

Attributes

image  [RW]  The image to be manipulated by operators.

Public Class methods

Create a new image operator proxy. Just provide the name of the image

[Source]

    # File lib/fleximage/image_proxy.rb, line 21
21:     def initialize(image, model_obj)
22:       @image = image
23:       @model = model_obj
24:     end

Public Instance methods

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.

[Source]

    # 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

[Validate]