Class: GameShelf

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/game_shelf.rb

Overview

Schema Information

Table name: game_shelves

id         :integer          not null, primary key
user_id    :integer
title      :string(255)
shelf_type :integer
created_at :datetime
updated_at :datetime

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.unknownObject


33
34
35
# File 'app/models/game_shelf.rb', line 33

def self.unknown
	return :game_shelf_unknown
end

.user_shelves(user_id) ⇒ Object


37
38
39
# File 'app/models/game_shelf.rb', line 37

def self.user_shelves(user_id)
	GameShelf.where(:user_id => user_id).order(:shelf_type)
end

Instance Method Details

#contains(game) ⇒ Object


21
22
23
# File 'app/models/game_shelf.rb', line 21

def contains(game)
	return self.shelf_items.where(item_id: game.id).count > 0
end

#find_item(game) ⇒ Object


25
26
27
# File 'app/models/game_shelf.rb', line 25

def find_item(game)
	return self.shelf_items.where(item_id: game.id).first
end

#is_custom_shelf?Boolean


29
30
31
# File 'app/models/game_shelf.rb', line 29

def is_custom_shelf?
	return self.shelf_type == GameShelf.shelf_types[:custom]
end