Class: Category
- Inherits:
-
Vyapari::ApplicationRecord
- Object
- ActiveRecord::Base
- Vyapari::ApplicationRecord
- Category
- 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
101 102 103 |
# File 'app/models/category.rb', line 101 def default_image_url(size="medium") "/assets/defaults/category-#{size}.png" end |
#display_name ⇒ Object
105 106 107 |
# File 'app/models/category.rb', line 105 def display_name self.name end |
#publish! ⇒ Object
change the status to :published Return the status
Examples
>>> category.publish!
=> "published"
63 64 65 |
# File 'app/models/category.rb', line 63 def publish! self.update_attribute(:status, PUBLISHED) end |
#published? ⇒ Boolean
-
Return true if the category is published, else false.
Examples
>>> category.published?
=> true
54 55 56 |
# File 'app/models/category.rb', line 54 def published? (status == PUBLISHED) end |
#remove! ⇒ Object
change the status to :removed Return the status
Examples
>>> category.remove!
=> "removed"
97 98 99 |
# File 'app/models/category.rb', line 97 def remove! self.update_attribute(:status, REMOVED) end |
#removed? ⇒ Boolean
-
Return true if the category is removed, else false.
Examples
>>> category.removed?
=> true
88 89 90 |
# File 'app/models/category.rb', line 88 def removed? (status == REMOVED) end |
#unpublish! ⇒ Object
change the status to :unpublished Return the status
Examples
>>> category.unpublish!
=> "unpublished"
80 81 82 |
# File 'app/models/category.rb', line 80 def unpublish! self.update_attribute(:status, UNPUBLISHED) end |
#unpublished? ⇒ Boolean
-
Return true if the category is unpublished, else false.
Examples
>>> category.unpublished?
=> true
71 72 73 |
# File 'app/models/category.rb', line 71 def unpublished? (status == UNPUBLISHED) end |