Class: DiscourseDev::Tag

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

Constant Summary

Constants inherited from Record

Record::AUTO_POPULATED, 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.



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

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

Instance Method Details

#create!Object



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

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

#dataObject



25
26
27
# File 'lib/discourse_dev/tag.rb', line 25

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

#populate!Object



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

def populate!
  return unless SiteSetting.tagging_enabled
  super
end