Module: RailsUploads::ActiveRecord::Base::ClassMethods

Defined in:
lib/rails_uploads/active_record/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



58
59
60
# File 'lib/rails_uploads/active_record/base.rb', line 58

def attachments
  @attachments
end

Class Method Details

.extended(base) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/rails_uploads/active_record/base.rb', line 60

def self.extended(base)
  [:file, :image].each do |type|
    base.send(:define_singleton_method, "attached_#{type}") do |*args|
      options = args.extract_options!
      options[:type] = type
      define_attachment *args.append(options)
    end
  end
end

Instance Method Details

#inherited(subclass) ⇒ Object



70
71
72
73
# File 'lib/rails_uploads/active_record/base.rb', line 70

def inherited(subclass)
  subclass.instance_variable_set(:@attachments, @attachments)
  super
end

#is_attachable?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/rails_uploads/active_record/base.rb', line 75

def is_attachable?
  attachments.present?
end