Class: BitCore::ContentModule
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BitCore::ContentModule
- Defined in:
- app/models/bit_core/content_module.rb
Overview
A logical unit of content, possibly containing mixed provider types.
Instance Method Summary collapse
- #add_content_provider(type) ⇒ Object
- #last_position ⇒ Object
-
#provider(position) ⇒ Object
Returns the ‘ContentProvider` at the given position, or a `Null` `ContentProvider` if none exists.
- #provider_exists?(position) ⇒ Boolean
Instance Method Details
#add_content_provider(type) ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/models/bit_core/content_module.rb', line 29 def add_content_provider(type) content_providers.build( type: type, position: next_position, show_next_nav: true ) end |
#last_position ⇒ Object
37 38 39 |
# File 'app/models/bit_core/content_module.rb', line 37 def last_position content_providers.order(:position).last.try(:position) || 0 end |
#provider(position) ⇒ Object
Returns the ‘ContentProvider` at the given position, or a `Null` `ContentProvider` if none exists.
20 21 22 23 |
# File 'app/models/bit_core/content_module.rb', line 20 def provider(position) content_providers.where(position: position).first || ContentProviders::Null.new(self, position) end |
#provider_exists?(position) ⇒ Boolean
25 26 27 |
# File 'app/models/bit_core/content_module.rb', line 25 def provider_exists?(position) content_providers.exists?(position: position) end |