Class: FilestackTransform

Inherits:
Object
  • Object
show all
Defined in:
lib/filestack_rails/transform.rb

Instance Method Summary collapse

Constructor Details

#initialize(apikey) ⇒ FilestackTransform

Returns a new instance of FilestackTransform.



4
5
6
7
8
9
10
11
# File 'lib/filestack_rails/transform.rb', line 4

def initialize(apikey)
    security = ::Rails.application.config.filestack_rails.security
    if !security.nil?
        @transform = Transform.new(apikey: apikey, security: security)
    else
        @transform = Transform.new(apikey: apikey)
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, **args) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/filestack_rails/transform.rb', line 13

def method_missing(method_name, **args)
    if defined? @transform.send(method_name)
        raise "Invalid transformation for filestack_image" unless scrub_bad_transforms(method_name)
        @transform = @transform.send(method_name, **args)
        self
    else
        super
    end
end

Instance Method Details

#add_external_url(url) ⇒ Object



23
24
25
# File 'lib/filestack_rails/transform.rb', line 23

def add_external_url(url)
    @transform.instance_variable_set(:@external_url, url)
end

#fs_urlObject



27
28
29
# File 'lib/filestack_rails/transform.rb', line 27

def fs_url
    @transform.url
end