Class: Caracal::Core::Models::LinkModel

Inherits:
TextModel show all
Defined in:
lib/caracal/core/models/link_model.rb

Overview

This class encapsulates the logic needed to store and manipulate link data.

Instance Attribute Summary collapse

Attributes inherited from TextModel

#text_bgcolor, #text_bold, #text_color, #text_content, #text_font, #text_highlight_color, #text_italic, #text_size, #text_style, #text_underline, #text_vertical_align

Instance Method Summary collapse

Methods inherited from TextModel

#run_attributes

Constructor Details

#initialize(options = {}, &block) ⇒ LinkModel

initialization



37
38
39
40
41
42
# File 'lib/caracal/core/models/link_model.rb', line 37

def initialize(options={}, &block)
  @text_color     = DEFAULT_LINK_COLOR
  @text_underline = DEFAULT_LINK_UNDERLINE

  super options, &block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Caracal::Core::Models::TextModel

Instance Attribute Details

readers (create aliases for superclass methods to conform to expected naming convention.)



23
24
25
# File 'lib/caracal/core/models/link_model.rb', line 23

def link_href
  @link_href
end

Returns the value of attribute link_internal.



24
25
26
# File 'lib/caracal/core/models/link_model.rb', line 24

def link_internal
  @link_internal
end

Instance Method Details

#external?Boolean

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

Returns:

  • (Boolean)


68
69
70
# File 'lib/caracal/core/models/link_model.rb', line 68

def external?
  !link_internal
end

#valid?Boolean

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

Returns:

  • (Boolean)


75
76
77
78
# File 'lib/caracal/core/models/link_model.rb', line 75

def valid?
  a = [:content, :href]
  a.map { |m| send("link_#{ m }") }.compact.size == a.size
end