module Attachie::ClassMethods

Public Instance Methods

attachment(name, options = {}) click to toggle source
# File lib/attachie.rb, line 168
def attachment(name, options = {})
  self.attachments = attachments.merge(name => options)

  define_method name do |version = nil, options = {}|
    return instance_variable_get("@#{name}") if version.nil?

    attachment(name).version(version, options)
  end

  define_method "#{name}=" do |value|
    self.updated_at = Time.now if respond_to?(:updated_at=) && !value.nil?

    instance_variable_set "@#{name}", value
  end
end