Sha256: 451dbd622c215f585cd53af62069d8d921eb3ad621e5e3f3d63d95a055b6e9ac

Contents?: true

Size: 1.12 KB

Versions: 21

Compression:

Stored size: 1.12 KB

Contents

module Dradis::Plugins::ContentService
  module ContentBlocks
    extend ActiveSupport::Concern

    def all_content_blocks
      project.content_blocks
    end

    def create_content_block(args={})
      block_group    = args.fetch(:block_group, default_content_block_group)
      content        = args.fetch(:content, default_content_block_content)
      user_id        = args.fetch(:user_id)

      content_block = ContentBlock.new(
        content: content,
        block_group: block_group,
        project_id: project.id,
        user_id: user_id
      )

      if content_block.valid?
        content_block.save
      else
        try_rescue_from_length_validation(
          model: content_block,
          field: :content,
          text: content,
          msg: 'Error in create_content_block()',
          tail: plugin_details
        )
      end
    end

    private

    def default_content_block_content
      "create_content_block() invoked by #{plugin} without a :content parameter"
    end

    def default_content_block_group
      "create_content_block() invoked by #{plugin} without a :block_group parameter"
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
dradis-plugins-4.7.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-4.6.1 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-4.5.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-4.4.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-4.3.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-4.2.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-4.1.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-4.0.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.22.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.21.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.20.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.19.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.18.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.17.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.16.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.15.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.14.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.13.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.12.0 lib/dradis/plugins/content_service/content_blocks.rb
dradis-plugins-3.11.0 lib/dradis/plugins/content_service/content_blocks.rb