Class: Newsitem
Overview
require_relative ‘./mongoid/votable.rb’
Constant Summary
collapse
- TYPE_GALLERY =
:type_gallery
- TYPE_PHOTO =
:type_photo
- TYPE_REPORT =
:type_report
- TYPE_VIDEO =
:type_video
- PER_PAGE =
6
Mongoid::Votable::VOTE_POINT
Class Method Summary
collapse
Instance Method Summary
collapse
#down_voter_ids, #down_votes_count, #up_voter_ids, #up_votes_count, #vote, #vote_value, #votes_count, #votes_point
Methods included from Ish::Utils
#export
Class Method Details
.from_params(item) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/newsitem.rb', line 61
def self.from_params item
n = Newsitem.new
n.descr = item[:descr]
n.username = item[:username]
unless item[:report_id].blank?
n.report = Report.find item[:report_id]
end
unless item[:gallery_id].blank?
n.gallery = Gallery.find item[:gallery_id]
end
n.partial_name = item.partial_name unless item.partial_name.blank?
return n
end
|
Instance Method Details
#collect(export_object) ⇒ Object
93
94
95
96
97
98
|
# File 'lib/newsitem.rb', line 93
def collect export_object
export_object[:galleries][gallery.id.to_s] = gallery.id.to_s if gallery
export_object[:photos][photo.id.to_s] = photo.id.to_s if photo
export_object[:reports][report.id.to_s] = report.id.to_s if report
export_object[:videos][video.id.to_s] = video.id.to_s if video
end
|
#description ⇒ Object
29
30
31
|
# File 'lib/newsitem.rb', line 29
def description
descr
end
|
#export_fields ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/newsitem.rb', line 79
def export_fields
%w|
descr
gallery_id
image_path
link_path
map_id
name
photo_id
report_id
video_id
|
end
|
#gallery ⇒ Object
16
17
18
|
# File 'lib/newsitem.rb', line 16
def gallery
self.gallery_id ? Gallery.unscoped.find( self.gallery_id ) : nil
end
|
#item_type ⇒ Object
49
50
51
52
53
54
|
# File 'lib/newsitem.rb', line 49
def item_type
return TYPE_GALLERY if gallery_id
return TYPE_PHOTO if photo_id
return TYPE_REPORT if report_id
return TYPE_VIDEO if video_id
end
|