Class: Category

Inherits:
Vyapari::ApplicationRecord show all
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" => true, "Non Featured" => false}
{true => "Featured", false => "Non Featured"}

Instance Method Summary collapse

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_nameObject



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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


71
72
73
# File 'app/models/category.rb', line 71

def unpublished?
  (status == UNPUBLISHED)
end