Module: Gluttonberg::Content
- Defined in:
- lib/gluttonberg/content.rb,
lib/gluttonberg/content/block.rb,
lib/gluttonberg/content/workflow.rb,
lib/gluttonberg/content/clean_html.rb,
lib/gluttonberg/content/versioning.rb,
lib/gluttonberg/content/publishable.rb,
lib/gluttonberg/content/localization.rb,
lib/gluttonberg/content/slug_management.rb,
lib/gluttonberg/content/import_export_csv.rb,
lib/gluttonberg/content/block_localization.rb
Overview
The content module contains a whole bunch classes and mixins related to the pages, localizations, content models and helpers for rendering content inside of views.
Defined Under Namespace
Modules: Block, BlockLocalization, CleanHtml, ImportExportCSV, Localization, Publishable, SlugManagement, Versioning, Workflow
Constant Summary collapse
- @@content_associations =
nil
- @@non_localized_associations =
nil
- @@localizations =
{}
- @@localization_associations =
nil
- @@localization_classes =
nil
Class Method Summary collapse
-
.content_associations ⇒ Object
Return the collection of content association names.
-
.localization_associations ⇒ Object
Returns an array of the localization association names.
-
.localizations ⇒ Object
Returns a hash of content classes that are localized, keyed to the association name.
-
.non_localized_associations ⇒ Object
For each content class that is registered, a corresponding association is declared against the Page model.
-
.register_localization(assoc_name, klass) ⇒ Object
If a content class has the is_localized declaration, this method is used to register it so we can keep track of all localized content.
-
.setup ⇒ Object
This is called after the application loads so that we can define any extra associations or do house-keeping once everything is required and running.
Class Method Details
.content_associations ⇒ Object
Return the collection of content association names.
45 46 47 |
# File 'lib/gluttonberg/content.rb', line 45 def self.content_associations @@content_associations end |
.localization_associations ⇒ Object
Returns an array of the localization association names.
62 63 64 |
# File 'lib/gluttonberg/content.rb', line 62 def self.localization_associations @@localization_associations end |
.localizations ⇒ Object
Returns a hash of content classes that are localized, keyed to the association name.
57 58 59 |
# File 'lib/gluttonberg/content.rb', line 57 def self.localizations @@localizations end |
.non_localized_associations ⇒ Object
For each content class that is registered, a corresponding association is declared against the Page model. We need to keep track of these, which is what this method does. It just returns an array of the association names.
37 38 39 40 41 42 |
# File 'lib/gluttonberg/content.rb', line 37 def self.non_localized_associations @@non_localized_associations ||= begin non_localized = Block.classes.select {|c| !c.localized? } non_localized.collect {|c| c.association_name } end end |
.register_localization(assoc_name, klass) ⇒ Object
If a content class has the is_localized declaration, this method is used to register it so we can keep track of all localized content.
51 52 53 |
# File 'lib/gluttonberg/content.rb', line 51 def self.register_localization(assoc_name, klass) @@localizations[assoc_name] = klass end |
.setup ⇒ Object
This is called after the application loads so that we can define any extra associations or do house-keeping once everything is required and running
26 27 28 29 30 31 |
# File 'lib/gluttonberg/content.rb', line 26 def self.setup # Store the names of the associations in their own array for convenience @@localization_associations = @@localizations.keys @@localization_classes = @@localizations.values @@content_associations = Block.classes.collect { |k| k.association_name } end |