Class: Ems::Report
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ems::Report
- Extended by:
- FriendlyId
- Defined in:
- app/models/ems/report.rb
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #content_as_html ⇒ Object
-
#content_disposition ⇒ Symbol
Custom getter for content_disposition attribute to emulate ENUMs.
-
#content_disposition=(value) ⇒ Object
Custom setter for content_disposition attribute to emulate ENUMs.
-
#init ⇒ Object
Method to make sure we have all our default values set on the object.
- #is_live? ⇒ Boolean
- #should_generate_new_friendly_id? ⇒ Boolean
-
#status ⇒ Symbol
Custom getter for status attribute to emulate ENUMs.
-
#status=(value) ⇒ Object
Custom setter for status attribute to emulate ENUMs.
Class Method Details
.base_query(category = nil) ⇒ Object
106 107 108 109 110 |
# File 'app/models/ems/report.rb', line 106 def base_query(category=nil) q = self.joins(:category).where("publish_from <= :publish_from", {:publish_from => Time.now.strftime("%Y/%m/%d %H:00:00")}).where(:status => 'live') q = q.where('ems_categories.id' => category.id) if category return q end |
Instance Method Details
#as_json(options = {}) ⇒ Object
99 100 101 |
# File 'app/models/ems/report.rb', line 99 def as_json(={}) super( .merge( :include => [ :category, :channels, :tags ] ) ) end |
#content_as_html ⇒ Object
88 89 90 |
# File 'app/models/ems/report.rb', line 88 def content_as_html Kramdown::Document.new(content, :input => "BeanKramdown").to_html end |
#content_disposition ⇒ Symbol
Custom getter for content_disposition attribute to emulate ENUMs
78 79 80 |
# File 'app/models/ems/report.rb', line 78 def content_disposition read_attribute(:content_disposition).to_sym if read_attribute :content_disposition end |
#content_disposition=(value) ⇒ Object
Custom setter for content_disposition attribute to emulate ENUMs
84 85 86 |
# File 'app/models/ems/report.rb', line 84 def content_disposition= (value) write_attribute(:content_disposition, value.to_s) end |
#init ⇒ Object
Method to make sure we have all our default values set on the object
59 60 61 62 |
# File 'app/models/ems/report.rb', line 59 def init self.status ||= :draft self.content_disposition ||= :markdown end |
#is_live? ⇒ Boolean
93 94 95 |
# File 'app/models/ems/report.rb', line 93 def is_live? self.status === :live end |
#should_generate_new_friendly_id? ⇒ Boolean
6 7 8 |
# File 'app/models/ems/report.rb', line 6 def should_generate_new_friendly_id? not self.is_live? end |
#status ⇒ Symbol
Custom getter for status attribute to emulate ENUMs
66 67 68 |
# File 'app/models/ems/report.rb', line 66 def status read_attribute(:status).to_sym if read_attribute :status end |
#status=(value) ⇒ Object
Custom setter for status attribute to emulate ENUMs
72 73 74 |
# File 'app/models/ems/report.rb', line 72 def status= (value) write_attribute(:status, value.to_s) end |