Sha256: 4cfc4fd060e6587e93d7d2808e1db58f40ff25ebf8c0f3dbed45efeb0fb49e8f

Contents?: true

Size: 858 Bytes

Versions: 22

Compression:

Stored size: 858 Bytes

Contents

module DataCatalog
  
  class Source

    include MongoMapper::Document

    # == Attributes

    key :title,       String
    key :description, String
    key :url,         String
    key :raw,         Hash
    key :_keywords,   Array
    timestamps!

    # == Indices

    ensure_index :url

    # == Associations

    many :usages,
      :class_name  => 'DataCatalog::Usage',
      :foreign_key => :source_id

    many :categorizations,
      :class_name  => 'DataCatalog::Categorization',
      :foreign_key => :source_id

    def categories
      categorizations.map(&:category)
    end

    # == Validations

    validates_presence_of :title
    validates_presence_of :url
    
    # == Callbacks
    
    before_save :update_keywords
    def update_keywords
      self._keywords = DataCatalog::Search.process([title, description])
    end

  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sinatra_resource-0.4.21 examples/datacatalog/models/source.rb
sinatra_resource-0.4.20 examples/datacatalog/models/source.rb
sinatra_resource-0.4.19 examples/datacatalog/models/source.rb
sinatra_resource-0.4.18 examples/datacatalog/models/source.rb
sinatra_resource-0.4.17 examples/datacatalog/models/source.rb
sinatra_resource-0.4.16 examples/datacatalog/models/source.rb
sinatra_resource-0.4.15 examples/datacatalog/models/source.rb
sinatra_resource-0.4.14 examples/datacatalog/models/source.rb
sinatra_resource-0.4.13 examples/datacatalog/models/source.rb
sinatra_resource-0.4.12 examples/datacatalog/models/source.rb
sinatra_resource-0.4.11 examples/datacatalog/models/source.rb
sinatra_resource-0.4.10 examples/datacatalog/models/source.rb
sinatra_resource-0.4.9 examples/datacatalog/models/source.rb
sinatra_resource-0.4.8 examples/datacatalog/models/source.rb
sinatra_resource-0.4.7 examples/datacatalog/models/source.rb
sinatra_resource-0.4.6 examples/datacatalog/models/source.rb
sinatra_resource-0.4.5 examples/datacatalog/models/source.rb
sinatra_resource-0.4.4 examples/datacatalog/models/source.rb
sinatra_resource-0.4.3 examples/datacatalog/models/source.rb
sinatra_resource-0.4.2 examples/datacatalog/models/source.rb