Class: Brand

Inherits:
Vyapari::ApplicationRecord show all
Defined in:
app/models/brand.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

#can_be_deleted?Boolean

TODO

Returns:

  • (Boolean)


96
97
98
99
100
101
102
103
104
# File 'app/models/brand.rb', line 96

def can_be_deleted?
  #if self.jobs.any?
  #  self.errors.add(:base, DELETE_MESSAGE) 
  #  return false
  #else
  #  return true
  #end
  return true
end

#default_image_url(size = "medium") ⇒ Object



110
111
112
# File 'app/models/brand.rb', line 110

def default_image_url(size="medium")
  "/assets/defaults/brand-#{size}.png"
end

#display_nameObject



106
107
108
# File 'app/models/brand.rb', line 106

def display_name
  self.name
end

#publish!Object

change the status to :published Return the status

Examples

>>> brand.publish!
=> "published"


57
58
59
# File 'app/models/brand.rb', line 57

def publish!
  self.update_attribute(:status, PUBLISHED)
end

#published?Boolean

  • Return true if the brand is published, else false.

Examples

>>> brand.published?
=> true

Returns:

  • (Boolean)


48
49
50
# File 'app/models/brand.rb', line 48

def published?
  (status == PUBLISHED)
end

#remove!Object

change the status to :removed Return the status

Examples

>>> brand.remove!
=> "removed"


91
92
93
# File 'app/models/brand.rb', line 91

def remove!
  self.update_attributes(status: REMOVED, featured: false)
end

#removed?Boolean

  • Return true if the brand is removed, else false.

Examples

>>> brand.removed?
=> true

Returns:

  • (Boolean)


82
83
84
# File 'app/models/brand.rb', line 82

def removed?
  (status == REMOVED)
end

#unpublish!Object

change the status to :unpublished Return the status

Examples

>>> brand.unpublish!
=> "unpublished"


74
75
76
# File 'app/models/brand.rb', line 74

def unpublish!
  self.update_attributes(status: UNPUBLISHED, featured: false)
end

#unpublished?Boolean

  • Return true if the brand is unpublished, else false.

Examples

>>> brand.unpublished?
=> true

Returns:

  • (Boolean)


65
66
67
# File 'app/models/brand.rb', line 65

def unpublished?
  (status == UNPUBLISHED)
end