Module: Attach::Attachment::ClassMethods
- Defined in:
- lib/attach/attachment.rb
Overview
class << self
Instance Method Summary collapse
-
#attachment_properties ⇒ Object
Setup properties.
Instance Method Details
#attachment_properties ⇒ Object
Setup properties. Already added properties are not overriden.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/attach/attachment.rb', line 13 def () klass = self [ [:id, DataMapper::Property::Serial], [:filename, String], [:content_type, String], [:size, Integer], [:attachable_id, Integer], [:attachable_type, String], [:field_name, String], # Default position may be rather high, but I don't really care [:position, Integer, {:default => Proc.new { |photo, prop| (klass.max(:position) || -1) + 1 }}], [:created_at, DateTime], [:updated_at, DateTime] ].each do |args| unless self.properties.named?(args[0]) self.property(*args) end end end |