Module: Imgix::ModelExtensions::ClassMethods
- Defined in:
- lib/imgix/model_extensions.rb
Instance Method Summary collapse
Instance Method Details
#has_imgix_attachment(name, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/imgix/model_extensions.rb', line 12 def (name, = {}) include InstanceMethods imgix_config.base_url(.delete(:base_url)) imgix_config.protocol(.delete(:protocol)) imgix_config.subdomain(.delete(:subdomain)) define_method(name) do |*args| a = Imgix::Attachment.new(name, self, ) end # simple helper method to use instead of having to use # the name provided define_method("imgix_attachment") do || self.send(name) end # Define how the setter of our attachment works # define_method "#{name}=" do |file| # attachment_for(name).assign(file) # end # Determine if the attachment is valid # define_method "#{name}?" do # attachment_for(name).file? # end end |