Sha256: c6b569de359aed27767533015019462f797182bee2d46a8ce10398878501cbe7
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
require 'caracal/core/models/text_model' module Caracal module Core module Models # This class encapsulates the logic needed to store and manipulate # link data. # class LinkModel < TextModel #------------------------------------------------------------- # Configuration #------------------------------------------------------------- # readers (create aliases for superclass methods to conform # to expected naming convention.) attr_reader :link_href alias_method :link_content, :text_content alias_method :link_style, :text_style alias_method :link_color, :text_color alias_method :link_size, :text_size alias_method :link_bold, :text_bold alias_method :link_italic, :text_italic alias_method :link_underline, :text_underline #------------------------------------------------------------- # Public Instance Methods #------------------------------------------------------------- #=============== SETTERS ============================== # strings [:href].each do |m| define_method "#{ m }" do |value| instance_variable_set("@link_#{ m }", value.to_s) end end #=============== VALIDATION =========================== def valid? a = [:content, :href] a.map { |m| send("link_#{ m }") }.compact.size == a.size end #------------------------------------------------------------- # Private Instance Methods #------------------------------------------------------------- private def option_keys (super + [:href]).flatten end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
caracal-0.1.1 | lib/caracal/core/models/link_model.rb |
caracal-0.1.0 | lib/caracal/core/models/link_model.rb |