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
30 31 32 33 34 35 36 |
# File 'app/models/bit_core/content_module.rb', line 30 def add_content_provider(type) content_providers.build( type: type, position: next_position, show_next_nav: true ) end |
#last_position ⇒ Object
38 39 40 |
# File 'app/models/bit_core/content_module.rb', line 38 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.
21 22 23 24 |
# File 'app/models/bit_core/content_module.rb', line 21 def provider(position) content_providers.find_by(position: position) || ContentProviders::Null.new(self, position) end |
#provider_exists?(position) ⇒ Boolean
26 27 28 |
# File 'app/models/bit_core/content_module.rb', line 26 def provider_exists?(position) content_providers.exists?(position: position) end |