Class: TagDb::Model::Tag

Inherits:
ActiveRecord::Base show all
Defined in:
lib/tagutils/tags/models/tag.rb,
lib/tagutils/tags/models/tag_comp.rb

Instance Method Summary collapse

Methods included from ClassMacros

#has_many_tags

Methods included from CategoryDb::ClassMacros

#has_many_categories

Instance Method Details

#keyObject

nb: only allow spaces and underscore inbetween;

do NOT allow digit as first char for now


12
# File 'lib/tagutils/tags/models/tag.rb', line 12

validates :key, format: { with: /#{TAG_KEY_PATTERN}/, message: TAG_KEY_PATTERN_MESSAGE }

#on_before_saveObject



21
22
23
24
25
26
27
# File 'lib/tagutils/tags/models/tag.rb', line 21

def on_before_save
  # replace space with dash e.g. north america becomes north_america and so on
  self.slug = key.gsub( ' ', '_' )

  ## if name is empty auto fill w/ key
  self.name = key   if name.blank?
end

#titleObject

alias for name (depreciated api calls)



11
# File 'lib/tagutils/tags/models/tag_comp.rb', line 11

def title()       name;              end

#title=(value) ⇒ Object



12
# File 'lib/tagutils/tags/models/tag_comp.rb', line 12

def title=(value) self.name = value; end