Module: ManageableContent::Controllers::Dsl::ClassMethods
- Defined in:
- lib/manageable_content/controllers/dsl.rb
Instance Method Summary collapse
-
#manageable_content_for(*keys) ⇒ Object
Configures the manageable contents for a Controller.
-
#manageable_layout_content_for(*keys) ⇒ Object
Configures the manageable contents that will be shared between all Controllers that use a given layout.
Instance Method Details
#manageable_content_for(*keys) ⇒ Object
Configures the manageable contents for a Controller. For example, if the Controller will have a ‘body’ and a ‘side’ contents, the following should be set:
manageable_content_for :body, :side
This will also inherit manageable contents from superclasses. For example, if all your Controllers will have a ‘title’ content, you can add the following to ApplicationController, and all Controllers which inherit from it will have it too:
manageable_content_for :title
You can also set a content type for the given keys. By default they are :text content types. Available types are :text for long contents and :string for short contents.
manageable_content_for :title, :type => :string
67 68 69 70 71 72 73 74 |
# File 'lib/manageable_content/controllers/dsl.rb', line 67 def manageable_content_for(*keys) = keys.last.is_a?(Hash) ? keys.pop : {} type = [:type] || :text if keys.present? self.manageable_content_keys = (self.manageable_content_keys.merge(keys_for_type(type, keys))) end end |
#manageable_layout_content_for(*keys) ⇒ Object
Configures the manageable contents that will be shared between all Controllers that use a given layout. For example, if all Controllers using the application layout will share a ‘footer_message’ and a ‘footer_copyright’ contents, the following should be set:
manageable_layout_content_for :footer_message, :footer_copyright
By default, this will set contents for a layout named the same as the Controller in which the manageable_layout_content_for method was called. For example, if it was called in the ApplicationController, it will set the layout vars for the ‘application’ layout. If you need to use multiple layouts with ApplicationController, you can specify for which layout are the contents being set with this:
manageable_layout_content_for :footer_message, :footer_copyright, :layout => 'application'
You can also set a content type for the given keys. By default they are :text content types. Available types are :text for long contents and :string for short contents.
manageable_layout_content_for :footer_copyright, :type => :string
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/manageable_content/controllers/dsl.rb', line 39 def manageable_layout_content_for(*keys) = keys.last.is_a?(Hash) ? keys.pop : {} layout = [:layout] || self.controller_path type = [:type] || :text if keys.present? Dsl.manageable_layout_content_keys[layout] = ((Dsl.manageable_layout_content_keys[layout] || {}).merge(keys_for_type(type, keys))) end end |