Class: DiscourseDev::Tag

Inherits:
Record
  • Object
show all
Defined in:
lib/discourse_dev/tag.rb

Constant Summary

Constants inherited from Record

Record::DEFAULT_COUNT

Instance Attribute Summary

Attributes inherited from Record

#model, #type

Instance Method Summary collapse

Methods inherited from Record

#current_count, populate!, random

Constructor Details

#initializeTag

Returns a new instance of Tag.



10
11
12
# File 'lib/discourse_dev/tag.rb', line 10

def initialize
  super(::Tag, DiscourseDev.config.tag[:count])
end

Instance Method Details

#create!Object



14
15
16
17
18
19
# File 'lib/discourse_dev/tag.rb', line 14

def create!
  super
rescue ActiveRecord::RecordInvalid => e
  # If the name is taken, try again
  retry
end

#dataObject



26
27
28
29
30
# File 'lib/discourse_dev/tag.rb', line 26

def data
  {
    name: Faker::Discourse.unique.tag,
  }
end

#populate!Object



21
22
23
24
# File 'lib/discourse_dev/tag.rb', line 21

def populate!
  return unless SiteSetting.tagging_enabled
  super
end