Sha256: ad2ca6e4aae9da5b8ebf9cd797bf648d00ee08bb06256d70fa76c3595d3b7d41

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

require Pathname(__FILE__).dirname / "image"
require Pathname(__FILE__).dirname / "commentable"
require Pathname(__FILE__).dirname / "viewable"
require Pathname(__FILE__).dirname / "taggable"
require Pathname(__FILE__).dirname / "user"
require Pathname(__FILE__).dirname / "bot"
require Pathname(__FILE__).dirname / "tag"

class Article
  include DataMapper::Resource

  property :id, Integer, :key => true, :serial => true
  property :title, String
  property :url, String


  remix 1, :images, :as => "pics"

  remix n, :viewables, :as => "views"

  remix n, :commentables, :as => "comments", :for => "User"

  remix n, "My::Nested::Remixable::Rating", :as => :ratings

  remix n, :taggable, :as => "user_taggings", :for => "User", :class_name => "UserTagging"

  remix n, :taggable, :as => "bot_taggings", :for => "Bot", :class_name => "BotTagging"

  enhance :viewables do
    belongs_to :user
  end

  enhance :taggable, "UserTagging" do
    belongs_to :user
    belongs_to :tag
  end

  enhance :taggable, "BotTagging" do
    belongs_to :bot
    belongs_to :tag
  end

  def viewed_by(usr)
    art_view = ArticleView.new
    art_view.ip = "127.0.0.1"
    art_view.user_id = usr.id

    self.views << art_view
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dm-is-remixable-0.9.7 spec/data/article.rb
dm-is-remixable-0.9.11 spec/data/article.rb
dm-is-remixable-0.9.10 spec/data/article.rb
dm-is-remixable-0.9.8 spec/data/article.rb
dm-is-remixable-0.9.9 spec/data/article.rb