Module: Resizing::CarrierWave
- Defined in:
- lib/resizing/carrier_wave.rb,
lib/resizing/carrier_wave/storage/file.rb,
lib/resizing/carrier_wave/storage/remote.rb
Defined Under Namespace
Modules: ClassMethods, Storage
Classes: Railtie
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Method Details
#build_url ⇒ Object
59
60
61
|
# File 'lib/resizing/carrier_wave.rb', line 59
def build_url
"#{Resizing.configure.image_host}#{model.read_attribute(serialization_column)}"
end
|
#cache!(new_file) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/resizing/carrier_wave.rb', line 95
def cache!(new_file)
return if new_file.nil?
file = storage.store!(new_file)
@filename = file.public_id.to_s
@file = file
end
|
140
141
142
|
# File 'lib/resizing/carrier_wave.rb', line 140
def default_format
@default_format
end
|
#default_url ⇒ Object
need override this. if you want to return some url when target_column is nil
64
65
66
|
# File 'lib/resizing/carrier_wave.rb', line 64
def default_url
nil
end
|
#file ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/resizing/carrier_wave.rb', line 34
def file
return if identifier.nil?
return @file unless defined? @file
@file ||= Resizing::CarrierWave::Storage::File.new(self)
@file.retrieve(identifier)
@file
end
|
#filename ⇒ Object
107
108
109
|
# File 'lib/resizing/carrier_wave.rb', line 107
def filename
read_column
end
|
144
145
146
|
# File 'lib/resizing/carrier_wave.rb', line 144
def format
requested_format || default_format
end
|
#initialize(*args) ⇒ Object
28
29
30
31
32
|
# File 'lib/resizing/carrier_wave.rb', line 28
def initialize(*args)
@requested_format = nil
@default_format = nil
super
end
|
#read_column ⇒ Object
55
56
57
|
# File 'lib/resizing/carrier_wave.rb', line 55
def read_column
model.read_attribute(serialization_column)
end
|
#remove_versions!(*args) ⇒ Object
130
131
132
|
# File 'lib/resizing/carrier_wave.rb', line 130
def remove_versions!(*args)
end
|
#rename ⇒ Object
76
77
78
|
# File 'lib/resizing/carrier_wave.rb', line 76
def rename
raise NotImplementedError, 'rename is not implemented'
end
|
134
135
136
137
138
|
# File 'lib/resizing/carrier_wave.rb', line 134
def requested_format
@requested_format
end
|
#resize_to_fill(*args) ⇒ Object
85
86
87
88
|
# File 'lib/resizing/carrier_wave.rb', line 85
def resize_to_fill(*args)
@transform ||= []
@transform.push(:resize_to_fill, *args)
end
|
#resize_to_fit(*args) ⇒ Object
90
91
92
93
|
# File 'lib/resizing/carrier_wave.rb', line 90
def resize_to_fit(*args)
@transform ||= []
@transform.push(:resize_to_fit, *args)
end
|
#resize_to_limit(*args) ⇒ Object
80
81
82
83
|
# File 'lib/resizing/carrier_wave.rb', line 80
def resize_to_limit(*args)
@transform ||= []
@transform.push(:resize_to_limit, *args)
end
|
#serialization_column ⇒ Object
116
117
118
|
# File 'lib/resizing/carrier_wave.rb', line 116
def serialization_column
model.send(:_mounter, mounted_as).send(:serialization_column)
end
|
#store! ⇒ Object
111
112
113
114
|
# File 'lib/resizing/carrier_wave.rb', line 111
def store!
super
end
|
#store_versions!(*args) ⇒ Object
123
124
125
|
# File 'lib/resizing/carrier_wave.rb', line 123
def store_versions!(*args)
end
|
68
69
70
71
72
73
74
|
# File 'lib/resizing/carrier_wave.rb', line 68
def transform_string
transforms = processors.map do |processor|
transform_string_from processor
end
transforms.join('/')
end
|
#url(*args) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/resizing/carrier_wave.rb', line 43
def url(*args)
return default_url unless read_column.present?
transforms = args.map do |version|
version = version.intern
raise "No version is found: #{version}, #{versions.keys} are exists." unless versions.has_key? version
versions[version].transform_string
end.compact
"#{build_url}/#{transforms.join('/')}"
end
|