Sha256: a373d21184149f763537e120e239a01ce775f22cc30e521c99274b83402896c7

Contents?: true

Size: 602 Bytes

Versions: 3

Compression:

Stored size: 602 Bytes

Contents

module DataCatalog

  class Categorization

    include MongoMapper::Document

    # == Attributes

    key :source_id,   Mongo::ObjectID
    key :category_id, Mongo::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.11 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.10 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.9 examples/datacatalog/models/categorization.rb