Class: Ems::Article
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ems::Article
- Extended by:
- FriendlyId
- Defined in:
- app/models/ems/article.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
109 110 111 112 113 |
# File 'app/models/ems/article.rb', line 109 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
97 98 99 |
# File 'app/models/ems/article.rb', line 97 def as_json(={}) super( .merge( :include => [ :category, :channels, :tags, :images ] ) ) end |
#content_as_html ⇒ Object
91 92 93 |
# File 'app/models/ems/article.rb', line 91 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
81 82 83 |
# File 'app/models/ems/article.rb', line 81 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
87 88 89 |
# File 'app/models/ems/article.rb', line 87 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
62 63 64 65 |
# File 'app/models/ems/article.rb', line 62 def init self.status ||= :draft self.content_disposition ||= :markdown end |
#is_live? ⇒ Boolean
102 103 104 |
# File 'app/models/ems/article.rb', line 102 def is_live? self.status === :live end |
#should_generate_new_friendly_id? ⇒ Boolean
7 8 9 |
# File 'app/models/ems/article.rb', line 7 def should_generate_new_friendly_id? not self.is_live? end |
#status ⇒ Symbol
Custom getter for status attribute to emulate ENUMs
69 70 71 |
# File 'app/models/ems/article.rb', line 69 def status read_attribute(:status).to_sym if read_attribute :status end |
#status=(value) ⇒ Object
Custom setter for status attribute to emulate ENUMs
75 76 77 |
# File 'app/models/ems/article.rb', line 75 def status= (value) write_attribute(:status, value.to_s) end |