Module: Gluttonberg::Content::Block
- Included in:
- HtmlContent, ImageContent, PlainTextContent
- Defined in:
- lib/gluttonberg/content/block.rb
Overview
This module can be mixed into a class to make it behave like a content block. A content block is a class that can be associated with a section on in a page description.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.classes ⇒ Object
An accessor which provides the collection of classes with mixin this module.
-
.included(klass) ⇒ Object
This included hook is used to declare the various properties and class ivars we need.
-
.register(klass) ⇒ Object
register content classes.
Class Method Details
.classes ⇒ Object
An accessor which provides the collection of classes with mixin this module.
45 46 47 |
# File 'lib/gluttonberg/content/block.rb', line 45 def self.classes @classes end |
.included(klass) ⇒ Object
This included hook is used to declare the various properties and class ivars we need.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gluttonberg/content/block.rb', line 12 def self.included(klass) klass.class_eval do extend Block::ClassMethods include Block::InstanceMethods cattr_accessor :localized, :label, :content_type, :association_name @localized = false attr_reader :current_localization belongs_to :page # Generate the various names to be used in associations type = self.name.demodulize.underscore self.association_name = type.pluralize.to_sym self.content_type = type.to_sym # Let's generate a label from the class — this might be over-ridden later self.label = type.humanize end end |
.register(klass) ⇒ Object
register content classes. We can do this inside included block, but in rails lazyloading behavior it is not properly working.
38 39 40 41 |
# File 'lib/gluttonberg/content/block.rb', line 38 def self.register(klass) @classes << klass @classes.uniq! end |