Sha256: 886d26833e3391a05bbf0fb953de21763846ca7cd6b23d6b149aa561a7d94c9d

Contents?: true

Size: 588 Bytes

Versions: 10

Compression:

Stored size: 588 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

10 entries across 10 versions & 1 rubygems

Version Path
sinatra_resource-0.4.21 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.20 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.19 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.18 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.17 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.16 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.15 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.14 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.13 examples/datacatalog/models/categorization.rb
sinatra_resource-0.4.12 examples/datacatalog/models/categorization.rb