Class: Faker::DiscourseMarkdown
- Inherits:
-
Markdown
- Object
- Markdown
- Faker::DiscourseMarkdown
- Defined in:
- lib/faker/discourse_markdown.rb
Class Attribute Summary collapse
Class Method Summary collapse
Class Attribute Details
.user_id ⇒ Object
12 13 14 |
# File 'lib/faker/discourse_markdown.rb', line 12 def user_id @user_id || ::Discourse::SYSTEM_USER_ID end |
Class Method Details
.image ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/faker/discourse_markdown.rb', line 26 def image image = next_image image_file = load_image(image) upload = ::UploadCreator.new(image_file, image[:filename], origin: image[:url]).create_for(user_id) ::UploadMarkdown.new(upload).to_markdown if upload.present? && upload.persisted? rescue => e STDERR.puts e STDERR.puts e.backtrace.join("\n") end |
.with_user(user_id) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/faker/discourse_markdown.rb', line 16 def with_user(user_id) current_user_id = self.user_id self.user_id = user_id begin yield ensure self.user_id = current_user_id end end |