Class: Caracal::Core::Models::BookmarkModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/caracal/core/models/bookmark_model.rb

Overview

This class encapsulates the logic needed to store and manipulate bookmarks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#initialize

Constructor Details

This class inherits a constructor from Caracal::Core::Models::BaseModel

Instance Attribute Details

#bookmark_idObject (readonly)

Returns the value of attribute bookmark_id.



19
20
21
# File 'lib/caracal/core/models/bookmark_model.rb', line 19

def bookmark_id
  @bookmark_id
end

#bookmark_nameObject (readonly)

Returns the value of attribute bookmark_name.



20
21
22
# File 'lib/caracal/core/models/bookmark_model.rb', line 20

def bookmark_name
  @bookmark_name
end

#bookmark_startObject (readonly)

accessors



18
19
20
# File 'lib/caracal/core/models/bookmark_model.rb', line 18

def bookmark_start
  @bookmark_start
end

Instance Method Details

#run_attributesObject

.run_attributes



30
31
32
33
34
35
36
# File 'lib/caracal/core/models/bookmark_model.rb', line 30

def run_attributes
  {
    start:          bookmark_start,
    id:             bookmark_id,
    name:           bookmark_name
  }
end

#start?Boolean

STATE HELPERS =========================

Returns:

  • (Boolean)


58
59
60
# File 'lib/caracal/core/models/bookmark_model.rb', line 58

def start?
  !!bookmark_start
end

#valid?Boolean

VALIDATION ============================

Returns:

  • (Boolean)


65
66
67
68
69
70
# File 'lib/caracal/core/models/bookmark_model.rb', line 65

def valid?
  a  = [:id]
  a << :name  if start?

  a.map { |m| send("bookmark_#{ m }") }.compact.size == a.size
end