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.
- #inspect ⇒ Object
-
#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
55 56 57 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 55 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.
33 34 35 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 33 def default_locale (self.locales.first || Locomotive::Mounter.locale).to_sym end |
#inspect ⇒ Object
59 60 61 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 59 def inspect "[MountingPoint] #{(self.resources || {}).keys.inspect}" end |
#locales ⇒ Array
Return all the locales defined by the site related to that mounting point.
24 25 26 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 24 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.
45 46 47 48 49 50 51 52 53 |
# File 'lib/locomotive/mounter/mounting_point.rb', line 45 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 |