Module: Gluttonberg::Content::Block::InstanceMethods

Defined in:
lib/gluttonberg/content/block.rb

Instance Method Summary collapse

Instance Method Details

#association_nameObject

The name of the generated association. This is the association that



116
117
118
# File 'lib/gluttonberg/content/block.rb', line 116

def association_name
  self.class.association_name
end

#content_typeObject

Content type is simply the inflected version of the content class name, e.g. FooContent becomes :foo_content



131
132
133
# File 'lib/gluttonberg/content/block.rb', line 131

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



137
138
139
140
141
142
143
# File 'lib/gluttonberg/content/block.rb', line 137

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.

Returns:

  • (Boolean)


111
112
113
# File 'lib/gluttonberg/content/block.rb', line 111

def localized?
  self.class.localized?
end

#sectionObject

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.



106
107
108
# File 'lib/gluttonberg/content/block.rb', line 106

def section
  @section ||= page.description.sections[section_name.to_sym]
end

#section_labelObject



121
122
123
# File 'lib/gluttonberg/content/block.rb', line 121

def 
  section[:label]
end

#section_positionObject



125
126
127
# File 'lib/gluttonberg/content/block.rb', line 125

def section_position
  section[:position]
end