Class: Category
- Inherits:
-
Vyapari::ApplicationRecord
- Object
- ActiveRecord::Base
- Vyapari::ApplicationRecord
- Category
- Extended by:
- PoodleValidators
- Defined in:
- app/models/category.rb
Constant Summary collapse
- PUBLISHED =
Constants
"published"- UNPUBLISHED =
"unpublished"- REMOVED =
"removed"- STATUS_HASH =
{"Published" => PUBLISHED, "Unpublished" => UNPUBLISHED, "Removed" => REMOVED}
- STATUS_HASH_REVERSE =
{PUBLISHED => "Published", UNPUBLISHED => "Unpublished", REMOVED => "Removed"}
- FEATURED_HASH =
{"Featured" => true, "Non Featured" => false}
- FEATURED_HASH_REVERSE =
{true => "Featured", false => "Non Featured"}
Instance Method Summary collapse
- #default_image_url(size = "medium") ⇒ Object
- #display_name ⇒ Object
-
#publish! ⇒ Object
change the status to :published Return the status == Examples >>> category.publish! => “published”.
-
#published? ⇒ Boolean
-
Return true if the category is published, else false.
-
-
#remove! ⇒ Object
change the status to :removed Return the status == Examples >>> category.remove! => “removed”.
-
#removed? ⇒ Boolean
-
Return true if the category is removed, else false.
-
-
#unpublish! ⇒ Object
change the status to :unpublished Return the status == Examples >>> category.unpublish! => “unpublished”.
-
#unpublished? ⇒ Boolean
-
Return true if the category is unpublished, else false.
-
Instance Method Details
#default_image_url(size = "medium") ⇒ Object
102 103 104 |
# File 'app/models/category.rb', line 102 def default_image_url(size="medium") "/assets/defaults/category-#{size}.png" end |
#display_name ⇒ Object
106 107 108 |
# File 'app/models/category.rb', line 106 def display_name self.name end |
#publish! ⇒ Object
change the status to :published Return the status
Examples
>>> category.publish!
=> "published"
64 65 66 |
# File 'app/models/category.rb', line 64 def publish! self.update_attribute(:status, PUBLISHED) end |
#published? ⇒ Boolean
-
Return true if the category is published, else false.
Examples
>>> category.published?
=> true
55 56 57 |
# File 'app/models/category.rb', line 55 def published? (status == PUBLISHED) end |
#remove! ⇒ Object
change the status to :removed Return the status
Examples
>>> category.remove!
=> "removed"
98 99 100 |
# File 'app/models/category.rb', line 98 def remove! self.update_attribute(:status, REMOVED) end |
#removed? ⇒ Boolean
-
Return true if the category is removed, else false.
Examples
>>> category.removed?
=> true
89 90 91 |
# File 'app/models/category.rb', line 89 def removed? (status == REMOVED) end |
#unpublish! ⇒ Object
change the status to :unpublished Return the status
Examples
>>> category.unpublish!
=> "unpublished"
81 82 83 |
# File 'app/models/category.rb', line 81 def unpublish! self.update_attribute(:status, UNPUBLISHED) end |
#unpublished? ⇒ Boolean
-
Return true if the category is unpublished, else false.
Examples
>>> category.unpublished?
=> true
72 73 74 |
# File 'app/models/category.rb', line 72 def unpublished? (status == UNPUBLISHED) end |