Module: Gluttonberg::Content::Block::InstanceMethods
- Defined in:
- lib/gluttonberg/content/block.rb
Instance Method Summary collapse
-
#association_name ⇒ Object
The name of the generated association.
-
#content_type ⇒ Object
Content type is simply the inflected version of the content class name, e.g.
-
#load_localization(id_or_model) ⇒ Object
Loads a localized version based on the specified page localization, then stashes it in an accessor.
-
#localized? ⇒ Boolean
Checks to see if this content class has localized properties.
-
#section ⇒ Object
Returns the section this content instance is associated with.
- #section_label ⇒ Object
- #section_position ⇒ Object
Instance Method Details
#association_name ⇒ Object
The name of the generated association. This is the association that
118 119 120 |
# File 'lib/gluttonberg/content/block.rb', line 118 def association_name self.class.association_name end |
#content_type ⇒ Object
Content type is simply the inflected version of the content class name, e.g. FooContent becomes :foo_content
133 134 135 |
# File 'lib/gluttonberg/content/block.rb', line 133 def content_type self.class.content_type end |
#load_localization(id_or_model) ⇒ Object
Loads a localized version based on the specified page localization, then stashes it in an accessor
139 140 141 142 143 144 145 |
# File 'lib/gluttonberg/content/block.rb', line 139 def load_localization(id_or_model) if localized? localization_id = id_or_model.is_a?(Numeric) ? id_or_model : id_or_model.id conditions = {:page_localization_id => localization_id, :"#{self.class.content_type}_id" => id} @current_localization = localizations.find(:first , :conditions => conditions) end end |
#localized? ⇒ Boolean
Checks to see if this content class has localized properties.
113 114 115 |
# File 'lib/gluttonberg/content/block.rb', line 113 def localized? self.class.localized? end |
#section ⇒ Object
Returns the section this content instance is associated with. It does this by looking at the associated page, it’s description then the matching section.
108 109 110 |
# File 'lib/gluttonberg/content/block.rb', line 108 def section @section ||= page.description.sections[section_name.to_sym] end |
#section_label ⇒ Object
123 124 125 |
# File 'lib/gluttonberg/content/block.rb', line 123 def section_label section[:label] end |
#section_position ⇒ Object
127 128 129 |
# File 'lib/gluttonberg/content/block.rb', line 127 def section_position section[:position] end |