Sha256: 6f1e7ad6366ce8cbd1a83d5580266035bd627fdabbd67eec786faf7fc18daee5

Contents?: true

Size: 584 Bytes

Versions: 3

Compression:

Stored size: 584 Bytes

Contents

module DataCatalog

  class Categorization

    include MongoMapper::Document

    # == Attributes

    key :source_id,   ObjectId
    key :category_id, ObjectId
    timestamps!

    # == Indices

    # == Associations

    belongs_to :source,   :class_name => 'DataCatalog::Source'
    belongs_to :category, :class_name => 'DataCatalog::Category'

    # == Validations

    validate :validate_associations

    def validate_associations
      errors.add(:source_id, "must be valid") if source.nil?
      errors.add(:category_id, "must be valid") if category.nil?
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sinatra_resource-0.4.24 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.23 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.22 examples/datacatalog/models/categorization.rb