Module: Cms::Acts::ContentBlock::MacroMethods

Defined in:
lib/cms/acts/content_block.rb

Defined Under Namespace

Modules: InstanceMethods

Instance Method Summary collapse

Instance Method Details

#acts_as_content_block(options = {}) ⇒ Object

Adds Content Block behavior to this class

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :allow_attachments (Boolean) — default: true

    Determines whether this content block can be marked as having attachments.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cms/acts/content_block.rb', line 15

def acts_as_content_block(options={})
  defaults = {
      # Set default values here.
      :allow_attachments => true
  }
  options = defaults.merge(options)

  if options[:belongs_to_attachment].present?
    raise ArgumentError.new ":belongs_to_attachment option is no longer supported. Please use :has_attachments option"
  end

  include Cms::DefaultAccessible
  allow_attachments if options[:allow_attachments]
  is_archivable(options[:archiveable].is_a?(Hash) ? options[:archiveable] : {}) unless options[:archiveable] == false
  is_connectable(options[:connectable].is_a?(Hash) ? options[:connectable] : {}) unless options[:connectable] == false
  flush_cache_on_change(options[:flush_cache_on_change].is_a?(Hash) ? options[:flush_cache_on_change] : {}) unless options[:flush_cache_on_change] == false
  is_renderable({:instance_variable_name_for_view => "@content_block"}.merge(options[:renderable].is_a?(Hash) ? options[:renderable] : {})) unless options[:renderable] == false
  is_publishable(options[:publishable].is_a?(Hash) ? options[:publishable] : {}) unless options[:publishable] == false
  is_searchable(options[:searchable].is_a?(Hash) ? options[:searchable] : {}) unless options[:searchable] == false
  uses_soft_delete(options[:soft_delete].is_a?(Hash) ? options[:soft_delete] : {}) unless options[:soft_delete] == false
  is_taggable(options[:taggable].is_a?(Hash) ? options[:taggable] : {}) if options[:taggable]
  is_userstamped(options[:userstamped].is_a?(Hash) ? options[:userstamped] : {}) unless options[:userstamped] == false
  is_versioned(options[:versioned].is_a?(Hash) ? options[:versioned] : {}) unless options[:versioned] == false

  include InstanceMethods
  extend Cms::Behaviors::Naming
end