Module: Crimagify::DinamicImageMethods
- Extended by:
- ActiveSupport::Concern
- Included in:
- Image
- Defined in:
- lib/crimagify/dinamic_image_methods.rb
Instance Method Summary collapse
Instance Method Details
#build_methods_images(methods = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/crimagify/dinamic_image_methods.rb', line 7 def build_methods_images(methods = nil) array_methods = [] CRIMAGIFY_ENV["#{self.name}"].each do |item| array_methods << item.first end array_methods.each do |name| define_method("#{name}") do img = crimagify_images.find_by_image_name("#{name}")# rescue "" if img == nil return [] else return img end end end end |
#build_sizes_images ⇒ Object
(methods = nil)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/crimagify/dinamic_image_methods.rb', line 25 def build_sizes_images#(methods = nil) array_versions = [] CRIMAGIFY_ENV.each do |image_name| image_name[1].each do |name| name_version = name[1] name_version.each do |item| array_versions << item.first end end end array_versions = array_versions.uniq array_versions.each do |name_size| size_image = name_size.to_sym define_method("#{name_size}") do image = image_url(size_image) rescue "" if image == "" if ENV['DEFAULT_IMAGE'].nil? image = "/crimagify/no_selected.png" else image = ENV['DEFAULT_IMAGE'] end end return image end end end |