Class: Locomotive::Section
- Inherits:
-
Object
- Object
- Locomotive::Section
- Includes:
- Concerns::Shared::JsonAttribute, Concerns::Shared::SiteScope, Concerns::Shared::Slug, Mongoid::Document
- Defined in:
- app/models/locomotive/section.rb
Instance Method Summary collapse
-
#_definition_schema ⇒ Object
Example: { “name”: “Header”, “settings”: [ { “label”: “Brand name”, “id”: “brand”, “type”: “string” } ], “blocks”: [ { “name”: “Menu item”, “type”: “menu_item”, “settings”: [ { “label”: “Item item”, “id”: “title”, “type”: “text” }, { “label”: “Item link”, “id”: “url”, “type”: “text” }, { “label”: “Open a new tab”, “id”: “new_tab”, “type”: “boolean”, “default”: false } ] } ] }.
-
#by_id_or_slug ⇒ Object
named scopes ##.
-
#name ⇒ Object
behaviours ##.
-
#touch_site_attribute ⇒ Object
methods ##.
Instance Method Details
#_definition_schema ⇒ Object
Example: {
"name": "Header",
"settings": [
{
"label": "Brand name",
"id": "brand",
"type": "string"
}
],
"blocks": [
{
"name": "Menu item",
"type": "menu_item",
"settings": [
{
"label": "Item item",
"id": "title",
"type": "text"
},
{
"label": "Item link",
"id": "url",
"type": "text"
},
{
"label": "Open a new tab",
"id": "new_tab",
"type": "boolean",
"default": false
}
]
}
]
}
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'app/models/locomotive/section.rb', line 70 def _definition_schema { id: 'http://www.locomotive.cms/schemas/sections/definition2.json', definitions: { settings: { type: 'object', properties: { id: { type: 'string' }, label: { '$ref': '#/definitions/locale_string' }, type: { enum: ['text', 'image_picker', 'asset_picker', 'checkbox', 'select', 'url', 'radio', 'content_type', 'content_entry', 'hint', 'integer'] }, default: {} }, required: [:id, :type] }, blocks: { type: 'object', properties: { name: { '$ref': '#/definitions/locale_string' }, type: { type: 'string' }, limit: { type: 'integer' }, settings: { type: 'array', items: { '$ref': '#/definitions/settings' }, default: [] } }, required: [:type, :name] }, preset_blocks: { type: 'object', properties: { type: { type: 'string' } }, required: [:type] }, preset: { type: 'object', properties: { name: { '$ref': '#/definitions/locale_string' }, category: { '$ref': '#/definitions/locale_string' }, settings: { type: 'object' }, blocks: { type: 'array', items: { '$ref': '#/definitions/preset_blocks'} } }, required: [:name, :category] }, locale_string: { anyOf: [ { type: 'string' }, { type: 'object', patternProperties: { '^[a-z]*(-[A-z]*)*$': { 'type': 'string' } }, additionalProperties: false } ] } }, type: 'object', properties: { name: { '$ref': '#/definitions/locale_string' }, class: { type: 'string' }, settings: { type: 'array', items: { '$ref': '#/definitions/settings' } }, presets: { type: 'array', items: { '$ref': '#/definitions/preset' } }, blocks: { type: 'array', items: { '$ref': '#/definitions/blocks' } }, max_blocks: { type: 'integer' }, blocks_display: { enum: ['list', 'tree'] }, max_blocks_depth: { type: 'integer' }, default: { type: 'object', properties: { settings: { type: 'object' }, blocks: { type: 'array' } }, required: [:settings] } }, required: [:name, :settings] } end |
#by_id_or_slug ⇒ Object
named scopes ##
20 |
# File 'app/models/locomotive/section.rb', line 20 scope :by_id_or_slug, ->(id_or_slug) { all.or({ _id: id_or_slug }, { slug: id_or_slug }) } |
#name ⇒ Object
behaviours ##
10 |
# File 'app/models/locomotive/section.rb', line 10 field :name |
#touch_site_attribute ⇒ Object
methods ##
31 32 33 |
# File 'app/models/locomotive/section.rb', line 31 def touch_site_attribute :template_version end |