Sha256: edd615cac09f9f37db0a19feafee85525ebe105af2b3274cc3329e1d9479317f

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

module TentD
  module Model
    class PostAttachment
      include DataMapper::Resource

      storage_names[:default] = "post_attachments"

      property :id, Serial
      property :type, Text, :required => true, :lazy => false
      property :category, Text, :required => true, :lazy => false
      property :name, Text, :required => true, :lazy => false
      property :data, Text, :required => true
      property :size, Integer, :required => true
      timestamps :at

      belongs_to :post, 'TentD::Model::Post', :required => false
      belongs_to :post_version, 'TentD::Model::PostVersion', :required => false

      validates_presence_of :post_id, :if => lambda { |m| m.post_version_id.nil? }
      validates_presence_of :post_version_id, :if => lambda { |m| m.post_id.nil? }

      def as_json(options = {})
        super({ :exclude => [:id, :data, :post_id, :created_at, :updated_at] }.merge(options))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tentd-0.0.1 lib/tentd/model/post_attachment.rb