Class: Sinicum::Templating::AreaHandler
- Inherits:
-
Object
- Object
- Sinicum::Templating::AreaHandler
- Includes:
- Jcr::ApiClient
- Defined in:
- lib/sinicum/templating/area_handler.rb
Overview
Private: Handles the lookup and creation of Areas on the server.
Returns an Array of Strings with the available components or nil if no area could be identified.
Instance Method Summary collapse
Methods included from Jcr::ApiClient
Methods included from Logger
Instance Method Details
#lookup_or_create_area(base_node, area_name) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sinicum/templating/area_handler.rb', line 10 def lookup_or_create_area(base_node, area_name) result = nil if base_node && area_name.present? path = "/_templating/areas/initialize" response = api_post( path, body: { workspace: base_node.jcr_workspace, baseNodeUuid: base_node.uuid, areaName: area_name }) if response.ok? begin json = MultiJson.load(response.body) result = json["availableComponents"] rescue => e Rails.logger.error("Could not lookup area: " + e.to_s) nil end end end result end |