Class: Report
- Inherits:
-
Object
- Object
- Report
- Includes:
- Ish::Utils, Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/report.rb
Constant Summary collapse
- PER_PAGE =
10
Class Method Summary collapse
- .all ⇒ Object
- .clear ⇒ Object
- .list(conditions = { :is_trash => false }) ⇒ Object
- .paginates_per ⇒ Object
Instance Method Summary collapse
- #export_fields ⇒ Object
- #is_premium ⇒ Object
-
#item_type ⇒ Object
Can be one of: default (nil), longscroll, wordpress e.g.
- #premium? ⇒ Boolean
-
#premium_tier ⇒ Object
copy-paste.
Methods included from Ish::Utils
Class Method Details
.all ⇒ Object
76 77 78 |
# File 'lib/report.rb', line 76 def self.all self.where( :is_public => true, :is_trash => false ).order_by( :created_at => :desc ) end |
.clear ⇒ Object
80 81 82 83 84 |
# File 'lib/report.rb', line 80 def self.clear if Rails.env.test? self.unscoped.each { |r| r.remove } end end |
.list(conditions = { :is_trash => false }) ⇒ Object
66 67 68 69 |
# File 'lib/report.rb', line 66 def self.list conditions = { :is_trash => false } out = self.where( conditions ).order_by( :name => :asc ).limit( 100 ) [['', nil]] + out.map { |item| [ item.name, item.id ] } end |
.paginates_per ⇒ Object
72 73 74 |
# File 'lib/report.rb', line 72 def self.paginates_per self::PER_PAGE end |
Instance Method Details
#export_fields ⇒ Object
94 95 96 |
# File 'lib/report.rb', line 94 def export_fields %w| name descr | end |
#is_premium ⇒ Object
88 89 90 |
# File 'lib/report.rb', line 88 def is_premium premium_tier > 0 end |
#item_type ⇒ Object
Can be one of: default (nil), longscroll,
wordpress e.g. https://piousbox.com/wp-json/wp/v2/posts?slug=intro
ITEM_TYPES = %w| longscroll wordpress |
19 |
# File 'lib/report.rb', line 19 field :item_type, type: String |
#premium? ⇒ Boolean
91 |
# File 'lib/report.rb', line 91 def premium?; is_premium; end |
#premium_tier ⇒ Object
copy-paste
87 |
# File 'lib/report.rb', line 87 field :premium_tier, type: Integer, default: 0 |