Class: Locomotive::Mounter::MountingPoint
- Inherits:
-
Object
- Object
- Locomotive::Mounter::MountingPoint
- Defined in:
- lib/locomotive/mounter/mounting_point.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#root_page ⇒ Object
Returns the value of attribute root_page.
Instance Method Summary collapse
-
#default_locale ⇒ Symbol
Return the default locale which is the first locale defined for a site.
-
#locales ⇒ Array
Return all the locales defined by the site related to that mounting point.
- #method_missing(name, *args, &block) ⇒ Object
-
#register_resource(name, elements) ⇒ Object
Register a resource (site, pages, content types, …etc) and its elements.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
43 44 45 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 43 def method_missing(name, *args, &block) (self.resources || {})[name.to_sym] || super end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 6 def path @path end |
#resources ⇒ Object
Returns the value of attribute resources.
6 7 8 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 6 def resources @resources end |
#root_page ⇒ Object
Returns the value of attribute root_page.
6 7 8 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 6 def root_page @root_page end |
Instance Method Details
#default_locale ⇒ Symbol
Return the default locale which is the first locale defined for a site. If none, then use the current I18n locale.
21 22 23 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 21 def default_locale (self.locales.first || Locomotive::Mounter.locale).to_sym end |
#locales ⇒ Array
Return all the locales defined by the site related to that mounting point.
12 13 14 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 12 def locales self.site.locales || [] end |
#register_resource(name, elements) ⇒ Object
Register a resource (site, pages, content types, …etc) and its elements. It makes sure that all the elements get a pointer to that mounting point. The elements can be either an array, hash or even a single object (ex: site). For instance, for a page, it will be a hash whose key is the fullpath.
33 34 35 36 37 38 39 40 41 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 33 def register_resource(name, elements) self.resources ||= {} (elements.respond_to?(:values) ? elements.values : [*elements]).each do |element| element.mounting_point = self end self.resources[name.to_sym] = elements end |