Sha256: 1a9022b00d44a99e68596ce029ad0a1c4b5f41f78c5c11b6ee7e85f4288cdbfc

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

module Cms
  module Concerns
    module HasContentType

      # Adds ContentType information to the object.
      # @param [Hash] options
      # @option options [Symbol] :module The module name, same as would be passed to content_module()
      def has_content_type(options={})
        include InstanceMethods
        extend ClassMethods

        if options[:module]
          content_module options[:module]
        end

      end

      # Used as a marker for finding classes that implement Content Types.
      module InstanceMethods

      end

      module ClassMethods

        # Returns the Cms::ContentType which provides information about the content.
        def content_type
          Cms::ContentType.new(name: self.name)
        end

        # Allows a content block to configure which module it will be placed in.
        # @param [Symbol] module_name (Optional) Sets value if provided.
        # @return [Symbol] module_name
        def content_module(module_name=nil)
          if module_name
            @module_name = module_name
          end
          if @module_name
            @module_name
          else
            :general
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
browsercms-artirix-4.0.4 lib/cms/concerns/has_content_type.rb
browsercms-artirix-4.0.3.3 lib/cms/concerns/has_content_type.rb
browsercms-artirix-4.0.3.2 lib/cms/concerns/has_content_type.rb
browsercms-artirix-4.0.3.1 lib/cms/concerns/has_content_type.rb
browsercms-artirix-4.0.3 lib/cms/concerns/has_content_type.rb
browsercms-artirix-4.0.2 lib/cms/concerns/has_content_type.rb
browsercms-artirix-4.0.1.1 lib/cms/concerns/has_content_type.rb
browsercms-artirix-4.0.0.rc1.art4 lib/cms/concerns/has_content_type.rb
browsercms-4.0.0.rc1 lib/cms/concerns/has_content_type.rb
browsercms-4.0.0.beta lib/cms/concerns/has_content_type.rb
browsercms-4.0.0.alpha lib/cms/concerns/has_content_type.rb